aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes INNER CLASSES Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "INNER CLASSES" Watch "INNER CLASSES" New topic
Author

INNER CLASSES

PRITAM POTNIS
Greenhorn

Joined: Aug 31, 2000
Posts: 9
What is the difference between Local Inner Classes and
Member Inner Classes??
Please explain ...........
kishen uchil
Greenhorn

Joined: Aug 21, 2000
Posts: 14
hi there pritam.
heres' your answer:
MEMBER INNER CLASS: a member inner class is a named class defined as a member of the enclosing class.must be associated with an instance of the enclosing class.there can be multiple member inner classes inside an enclosing class.they can be declared as public,private,protected,final,or abstract but cannot have the same name as the enclosing class.
LOCAL INNER CLASS:a named class defined inside the code block of a method is known as a local inner class.the LOCAL INNER CLASS
can access the local variables in the metod and parameters passed to the method only if the variables are declared final.similar to a local variable the inner class cannot be accesed outside the code block in other words the scope of the class is confined to the code block.
member inner class e.g:
class a
{
class b //member iiner class
{
}
}
LOCAL INNER CLASS:
class a
{
void method()
{
class b //local inner class
{
}
}
}
hope this helps
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Have a look at this code

public class test
{
static public void main(String[]p)
{
// a local inner class
class te
{
// a method that is defined inside the local inner class
void get()
{
System.out.println("available only inside this class and is
restricted for use only within this method");
// accessing the member inner class method
new test().new te2().get2();
}
}
new te().get();
}
// a member inner class definition
class te2
{
void get2()
{
System.out.println("available in all methods and inner classes
except for static instances");
}
}
}
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: INNER CLASSES