aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Members of inner classes Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Members of inner classes" Watch "Members of inner classes" New topic
Author

Members of inner classes

Marcel Stör
Greenhorn

Joined: Apr 26, 2009
Posts: 3
On http://faq.javaranch.com/java/ScjpFaq#tripsTraps it says that

No inner class can have a static member.


While I might have misinterpreted the statement, it's certainly true that static inner classes may have static members:
Vishwanath Krishnamurthi
Ranch Hand

Joined: Jun 04, 2007
Posts: 330
Hi,

Its a common misconception. A static class that is nested in a class is called as "static nested class" and not as static inner class. That was the confusion I guess?

Terminolgy:
inner class => any non static nested class
Sun tutorial

Regards,
Vishwa


Blog
Marcel Stör
Greenhorn

Joined: Apr 26, 2009
Posts: 3
Was I ignorant all those many years that I've been programming Java? I really wasn't aware of the difference in terminology...

Thanks for the link, but IMO in that article even Sun makes a mess out of those terms. At the end they quite correctly admit that
...the taxonomy of the different kinds of classes in the Java programming language (which can be tricky to describe concisely, clearly, and correctly),...


Today is a good day - I learned something

Regards,
Marcel
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1790
Yes..static inner classes called as the nested classes..the following program will not work. because it declares static field inside a inner class.


Krishna Srinivasan
Java Writers Needed
Robin Paul
Greenhorn

Joined: Mar 18, 2009
Posts: 13
Since your confusion is already clear please do remember that the modifier static always means that it belongs to class and is treated as member. That is why static inner class is called a member class and not inner. So if you do hear inner classes it will mostly refer to non static inner class and local inner classes.


Obstacles are the things we see when we take our eyes off our goals.
 
 
subject: Members of inner classes
 
Threads others viewed
Enum
Inner Access specifiers
khalid mughal
Accessibility of private methods in inner classes
Access to Inner Class private members
IntelliJ Java IDE