permaculture playing cards*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Top-level classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Top-level classes" Watch "Top-level classes" New topic
Author

Top-level classes

Deepak M
Ranch Hand

Joined: Jul 10, 2000
Posts: 124
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

Joined: Jul 24, 2000
Posts: 32
A static inner class is called "A top-level Inner Class"
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
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'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Top-level classes