File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes static inner classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "static inner classes" Watch "static inner classes" New topic
Author

static inner classes

Saral Saxena
Ranch Hand

Joined: Apr 22, 2011
Posts: 202

Hi Folks,

I was going through the concept of static inner classes and how their objects are created ...Guys please advise me or tell me a scenario where the static nested classes would be helpful ..and what performance impact would they bring out ...?
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3363
    
    9
Personally I like static inner classes as types that are only useful for helper objects inside the enclosing class, or when they're logically an internal part of the enclosing class and not significant enough to have a separate source file.

As an example, you could have the class ChessPiece.Color, which models the color of a chess piece; usually black or white. Here Color is logically an internal part of the ChessPiece.

There should be no performance penalty or benefit. To the JVM, they're the same as every other class. They're just another way for you to structure your code. I know many people don't like them and never use them.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: static inner classes
 
Similar Threads
Inner classes
Examples of all the types of inner classes
Inner classes
declaration of an inner class:
Inner Classes