Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Top-level classes

 
Deepak M
Ranch Hand
Posts: 124
  • 0
  • Mark post as helpful
  • send pies
  • 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)
 
Uvnik Gupta
Ranch Hand
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A static inner class is called "A top-level Inner Class"
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic