This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread 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 Android Security Essentials Live Lessons this week in the Android 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
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Inner classes
Similar Threads
Inner class or static member class
Member class can have static variables??
which one is correct
Static member classes and intefaces
answer please