This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes Inner classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Inner classes" Watch "Inner classes" New topic

Inner classes

Denis Denis

Joined: Apr 03, 2007
Posts: 5
Why inner classes cannot contain non-final static variables or static methods, but may them inherit.
What is the sense?
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
How is Debbie Harry these days? Still in love with you?

Sun says: -
Because an inner class is associated with an instance, it cannot define any static members itself.

I think that they could easily have allowed static members in inner classes, but they thought it would encourage poor programs, so forbade it. That may or may not have been a good decision, but we don't gain a huge amount by worrying about it!

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

"Denis Denis"

Welcome to Javaranch!

Please could you update your display name to comply with out Naming Policy. You can do this here.


(Also, this is not an advanced question, so I will more it somewhere more appropriate)

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
I agree. Here's the link:
subject: Inner classes