jQuery in Action, 3rd edition
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
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: http://aspose.com/file-tools
subject: Inner classes
It's not a secret anymore!