Order of Declaration of Class Members (ODCM)

Description:

Checks order of declaration of class members. In the options boxes, you can specify whether to check order according Sun Code Conventions for Java, or you wish to place public and package members first, before protected and private ones. .

According to Sun Code Conventions for Java, the parts of a class or interface declaration should appear in the following order:

  1. Class (static) variables. First the public class variables, then the protected, then package level (no access modifier), and then the private.
  2. Instance variables. First the public class variables, then the protected, then package level (no access modifier), and then the private.
  3. Constructors.
  4. Methods.

Example:

public class PMFL {
    void func1 () {}
    public static void main (String args[]) {} 
    void func2 () {}
}