Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inner classes

 
Denis Denis
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why inner classes cannot contain non-final static variables or static methods, but may them inherit.
What is the sense?
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic