Sunday, October 19, 2008

Declaration Rules

Declaration Rules (Objective 1.1)
  • A source code file can have only one public class.
  • If the source file contains a public class, the filename must match the public class name.
  • A file can have only one package statement, but multiple imports.
  • The package statement (if any) must be the first (non-comment) line in a source file.
  • The import statements (if any) must come after the package and before the class declaration.
  • If there is no package statement, import statements must be the first (noncomment) statements in the source file. package and import statements apply to all classes in the file.
  • A file can have more than one nonpublic class.
  • Files with no public classes have no naming restrictions.

No comments: