• 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

S & B Book - Inner Classes

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In S&B book, page 639 it has been mentioned that: "a regular inner class can't have static declarations of any kind."

But following code having final static field in an inner class compiles fine!



Have I misunderstood something or it is an error in book itself?

Murali...
SCJP 5 Aspirant
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Odds are that the book is referring to static method definitions. All static methods must be defined in a top-level class (or a static nested class, which for most purposes is a top-level class).

Edit: Additionally, static-nested classes can't be defined within regular inner classes. neither can non-final members.

Looks like the only static declaration allowed within an inner class is a final member variable.
[ July 11, 2007: Message edited by: Justin Searls ]
 
Why should I lose weight? They make bigger overalls. And they sure don't make overalls for tiny ads:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic