• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Rob Spoor
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:

INNER CLASSES

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the difference between Local Inner Classes and
Member Inner Classes??
Please explain ...........
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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");
}
}
}
 
We don't have time for this. We've gotta save the moon! Or check this out:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic