• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can somebody explain that what's the difference between class and inner class?

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I find that the inner class's instance variable can't be autoinitialized.
Are there any other differences?

best wishes.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by As Angel:
I find that the inner class's instance variable can't be autoinitialized...


Welcome to JavaRanch!

An instance variable of an inner class should get the same default value (binary zero) as a top-level class. Can you post some code demonstrating what you mean?
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi As Angel....

a class is an abstract model of a set or a group of things, having a basic set of qualities or properties....

you create instances of objects using the constructors provided by the class.

now...
any such class, if it has another class declared inside its signature... then the class declared inside is called the Inside class or the Inner class.
i.e., any class that is declared inside the curly braces of a previously declared class, is called the inner class to the outer class...

if you declare any new class outside the curly braces of an old class, then the class is not an inner class to the old class...
but if you declare this new class as...



then the newClass is a subclass of the oldClass... not an inner class of the
oldClass....

now ....

about instance variable's........

instance variable's belong to the Object created using the operator....

Instance variables are given default values..... irrespective of where its parent class has been declared....

the point is that they will always be auto initialized....

but local variables are not auto initialized....



understand....
 
reply
    Bookmark Topic Watch Topic
  • New Topic