• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

If static inner classes are top level classes then why does this compiles

 
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at the code if static inner classes are top level classes then private access modifier should not be allowed by the compiler. But this compiles.

[ April 30, 2003: Message edited by: Anupam Sinha ]
 
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Anupam Sinha:
Have a look at the code if static inner classes are top level classes then private access modifier should not be allowed by the compiler. But this compiles.
-Anupam Sinha ]


Why not private access modifier , i don't see anything problems in this. please elaborate!
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That exactly i want to say that i dont see any problem with it. A private static nested class is a top level class but a top level class can not be private. So does it means that static nested classes are not top level classes?
[ April 30, 2003: Message edited by: Anupam Sinha ]
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A static nested class is a static member of the outer class. So it can have all the modifiers a static member like var or method can have.
Rattan
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


So does it means that static nested classes are not top level classes?


Correct. Static nested classes are top-level nested classes, not top-level classes. Confusing terminology, I agree, but that's what it is.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic