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

Why non-static inner class cannot have static member

 
siddharth das
Ranch Hand
Posts: 131
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can you please tell why Why non-static inner class cannot have static member?

Thanks,
Siddharth
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has to do with the same thing as what I answered in your other topic. An instance of a non-static nested class is associated with an instance of its enclosing class.

The body of a non-static nested class is not a static scope, and therefore you can't have static members in there. In other words, the member variables and methods in the non-static nested class are relative to an instance of the enclosing class - they are not really at class level (where you could use static). It's a bit hard to explain, but if you've understood my answer in your other topic, I hope you'll understand this as well.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic