HOME            LINKS
Code Conventions for the Java Programming Language.

This Code Conventions for the Java Programming Language document contains the standard conventions that we at Sun follow and recommend that others follow. It covers filenames, file organization, indentation, comments, declarations, statements, white space, naming conventions, programming practices and includes a code example.

Why have code conventions?
File Suffix
Common File Names
Java Source File

Why have code conventions? Code conventions are important to programmers for a number of reasons:

  • 80% of the lifetime cost of a piece of software goes to maintenance.
  • Hardly any software is maintained for its whole life by the original author.
  • Code conventions improve the readability of the software, allowing engineers to understand new code more quickly and thoroughly.
  • If you ship your source code as a product, you need to make sure it is as well packaged and clean as any other product you create.

File Suffix

  • Java Source - *.java
  • Java bytecode - *.class

Common File Names

  • GNUmakefile - The preferred name for makefiles. We use gnumake to build our software.
  • README - The preferred name for the file that summarizes the contents of a particular directory.

File Organization

  • A file consists of sections that should be separated by blank lines and an optional comment identifying each section.
  • Files longer than 2000 lines are cumbersome and should be avoided.

Java Source File

  • Each Java source file contains a single public class or interface. When private classes and interfaces are associated with a public class, you can put them in the same source file as the public class. The public class should be the first class or interface in the file.

 

Back

We do not provide any software crack tools or hack tools.