aspose file tools*
The moose likes Java in General and the fly likes Discussion on Static Nested Classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Discussion on Static Nested Classes" Watch "Discussion on Static Nested Classes" New topic
Author

Discussion on Static Nested Classes

Larsen Raja
Ranch Hand

Joined: Nov 28, 2011
Posts: 58
Hi,

I would like to share my views and your views on Static Nested Classes.

From my analysis, I comclude that static Nested Classes are similar to a spearate non-inner class except it has a few privileges.

For ex:
Static Nested Classes can access static members of enclosing class witout namespace. To say, this behaviour is exaclty like a static method enclosed in a class.

Please share your views.

Larsen.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39851
    
  28
It should all be in the Java Language Specification, but the Java Tutorials are easier to understand.
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2267
    
    3

I myself avoid inner classes and static stuff as much as possible.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8239
    
  23

Roberto Perillo wrote:I myself avoid inner classes and static stuff as much as possible.

Actually, I find static nested classes (I don't like the term 'inner') very useful, because it defines exactly what I want: a class that only has meaning within the context of another class, and which should probably be qualified with it when used from outside (eg, AbstractMap.SimpleEntry).

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3649
    
  17

I agree, static nested classes can be great, especially when they're completely for the convenience of their enclosing class (like a tuple, or some other aggregation of data). In this case, you don't have to give them any methods, you can just use them as records and access their private fields directly.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Discussion on Static Nested Classes