7.6. Top Level Type Declarations
A top level type declaration declares a top level class type (§8) or a top level interface type (§9).
TypeDeclaration: ClassDeclaration InterfaceDeclaration ;
By default, the top level types declared in a package are accessible only within the compilation units of that package, but a type may be declared to be public
to grant access to the type from code in other packages (§6.6, §8.1.1, §9.1.1).
It is a compile-time error if a top level type declaration contains any one of the following access modifiers: protected
, private
, or static
.
It is a compile-time error if the name of a top level type appears as the name of any other top level class or interface type declared in the same package.
It is a compile-time ...
Get The Java® Language Specification, Java SE 7 Edition, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.