This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static inner classes

 
Saral Saxena
Ranch Hand
Posts: 203
Eclipse IDE Java Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 4838
34
Chrome Netbeans IDE Windows
  • 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic