This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

INNER CLASSES

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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");
}
}
}
 
Don't count your weasels before they've popped. And now for a mulberry bush related tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!