This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Member class vs inner class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Member class vs inner class" Watch "Member class vs inner class" New topic
Author

Member class vs inner class

Andy James
Ranch Hand

Joined: Aug 22, 2005
Posts: 90
Source: http://blogs.sun.com/darcy/entry/nested_inner_member_and_top

How are member classes different from nested classes (a static or non-static class declared within another class)? Article at the above mentioned link states that:

a member class -> must have a declaring class
an inner class -> must have an enclosing class.

I understand what the static and non-static inner classes are. The following code examples defines a static and non-static inner class.



Can someone please explain what is a member class? I could not make much of the following from the Java Language Specification doc:

8.5 A member class is a class whose declaration is directly enclosed in another class or interface declaration.


cheers
Andy
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
Nested classes are divided into two categories: static and non-static. Nested classes that are declared static are simply called static nested classes. Non-static nested classes are called inner classes or member classes.


SCJP 1.6 96%
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

There are four types of Inner classes,

1) Member classes/Regular inner classes
2) Method local Inner classes
3) Anonymous Inner classes
4) Static Inner classes.

And, What do you mean by members of a class? It's methods, instance variables? Like that, if a class defined within directly below a Top level class, it(the inner class) is a member of the outer class. So, it's also called as member classes.


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Member class vs inner class
 
Similar Threads
Difference between inner and nested classes ?
Query from JLS
Inner Class definition per JLS
Inner Class
Interface