wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Inner classes" Watch "Inner classes" New topic
Author

Inner classes

Denis Denis
Greenhorn

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
Bartender

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.

Thanks!

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


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
jQuery in Action, 2nd edition
 
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