Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

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 ]
 
This one time, at bandcamp, I had relations with a tiny ad.
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic