• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Static methods and fields in inner classes

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic