• Post Reply Bookmark Topic Watch Topic
  • New Topic

Static methods and fields in inner classes  RSS feed

 
Manfredo Kopfinger
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

Here something I just noticed. When you make an inner class inherit from another class that has static fields and methods, the inner class also has these static members, even though it cannot declare static members by itself.

Look at this piece of code:



With this method, the derived class has static and non-static members just like a top-level class, plus it can access the members of the enclosing class.

I wonder why the java designers didn't make inner classes just work like that, it would be much more logically to me.

Are there any technical reasons that that the java designer didn't implement it to work like that? Or is it bad practise?
[ May 31, 2006: Message edited by: Manfredo Kopfinger ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!