*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Inner Class 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 Class" Watch "Inner Class" New topic
Author

Inner Class

Fisher Daniel
Ranch Hand

Joined: Sep 14, 2001
Posts: 582
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
Rodney Woodruff
Ranch Hand

Joined: Dec 04, 2001
Posts: 80
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.


Hope This Helps
Fisher Daniel
Ranch Hand

Joined: Sep 14, 2001
Posts: 582
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
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
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 ]

SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Jamal Hasanov
Ranch Hand

Joined: Jan 08, 2002
Posts: 411
Fisher, in Your question,
Nested Class - means Inner class inside other class
Inner Class - means Inner class inside method
That's all.
Axl Rose
Greenhorn

Joined: Dec 18, 2000
Posts: 16
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 )
Erik Dark
Ranch Hand

Joined: Jan 28, 2002
Posts: 107
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
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Sound like nitpicking
Not at all! Accuracy and precise terminology is of paramount importance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inner Class