Java Reference
In-Depth Information
A version number can be a simple number, a date, or other format. The important thing is that a
reader must be able to recognize whether two versions are different and to determine which one
is newer.
J.3.2 Every method has a method comment
J.3.3 Comments are Javadoc-readable
Class and method comments must be recognized by Javadoc. In other words, they should start
with the comment symbol “ /** ”.
J.3.4 Code comments (only) where necessary
Comments in the code should be included where the code is not obvious or is difficult to under-
stand (and preference should be given to make the code obvious or easy to understand where
possible) and where comments facilitate understanding of a method. Do not comment obvious
statements—assume that your reader understands Java!
Language-use restrictions
J.4.1 Order of declarations: Fields, constructors, methods
The elements of a class definition appear (if present) in the following order: package statement;
import statements; class comment; class header; field definitions; constructors; methods; inner
J.4.2 Fields may not be public (except for final fields)
J.4.3 Always use an access modifier
Specify all fields and methods as either private , public , or protected . Never use default
(package private) access.
J.4.4 Import classes separately
Importing statements explicitly naming every class are preferred over importing whole pack-
ages. For example:
import java.util.ArrayList;
import java.util.HashSet;
is better than
import java.util.*;
J.4.5 Always include a constructor (even if the body is empty)
Search WWH ::

Custom Search