• 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

Top-level classes

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JLS 2 Chapter 8 :
A nested class is any class whose declaration occurs within the body of another class or interface. A top level class is a class that is not a nested class.
Inner classes specification : http://java.sun.com/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc1.html
In addition, the programmer can define a class as a static member of any top-level class. Classes which are static class members and classes which are package members are both called top-level classes
SO,
package com.deepak;
class Outer {
static class IsThisTopLevel { }
}
Is the class 'IsThisTopLevel' a top level class (as per the Inner class specs) or just a nested class (as per JLS2)
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A static inner class is called "A top-level Inner Class"
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JLS2 has changed the definition of "top-level". Before JLS2, "top-level" could mean regular top-level, or top-level nested (the so-called "static inner" class). But that evidently just confused people, so under JLS2 they've changed top-level to mean only "regular" top-level, never any sort of nested class. Under JLS2 the former top-level nested ("static inner")classes are now called static member classes.
Note that static member classes are not, and never have been, true inner classes, so the term "static inner class" is incorrect, though widely used anyway.
 
reply
    Bookmark Topic Watch Topic
  • New Topic