• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Inner Class

 
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all, i have some problem with inner class
1. What is the meaning of inner class and nested class ?
2. Can you explain to me what the differences between inner class and nested class ?
thanks
daniel
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Fisher,
Your question is really broad. Can you narrow it a little bit?
Also, this question has probably been discussed at length in this form. Therefore a search might return and load of valuable info.
 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
actually I have a question like this..
Which of the following statements are true?
a. Non-static inner classes must have either defaul or public accessibility
b. Non-static inner classes cannot contain static members
c. Methods in all nested classes can be declared static
d. all nested classes can be declared static
e. A static inner class can declare contain a non-static inner class
the answer is e..
Why is option b wrong?
thanks
daniel
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good places to start looking for an answer are
JLS 8.1.2 Inner Classes and Enclosing Instances
JLS 14.3 Local Class Declarations
JLS 15.9.5 Anonymous Class Declarations
JLS 8.5 Member Type Declarations
[ March 12, 2002: Message edited by: Valentin Crettaz ]
 
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Fisher, in Your question,
Nested Class - means Inner class inside other class
Inner Class - means Inner class inside method
That's all.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jamal, you are not totally correct.
see JLS inner classes.
basically inner classes: are classes that are not decalred 'static'.
nested classes: are classes that are static.
it doesn't matter if the class is inside a method or not.
ok Mr Hasan( ov )
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Axl, you are not totally correct:

JLS: An inner class is a nested class that is not explicitly or implicitly declared static.

So NESTED CLASSES can be divided in (not-static) INNER CLASSES (local, anonymous and non-static members) and STATIC MEMBER CLASSES.
Sound like nitpicking but the confusing is all around about this (even in some books!).
Erik Dark
[ March 14, 2002: Message edited by: Erik Dark ]
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sound like nitpicking
Not at all! Accuracy and precise terminology is of paramount importance.
 
Honk if you love justice! And honk twice for tiny ads!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic