class ExampleClass {
// Access modifiers first (don't do for instance "static public")
public static void main(String[] args) {
System.out.println("Hello World");
}
}
interface ExampleInterface {
// Avoid 'public' and 'abstract' since they are implicit
void sayHello();
}
Modifiers should go in the following order
public
/ private
/ protected
)abstract
static
final
transient
volatile
default
synchronized
native
strictfp
Modifiers should not be written out when they are implicit. For example, interface methods should neither be declared public
nor abstract
, and nested enums and interfaces should not be declared static.
Method parameters and local variables should not be declared final
unless it improves readability or documents an actual design decision.
Fields should be declared final
unless there is a compelling reason to make them mutable.