31 lines
577 B
Plaintext
31 lines
577 B
Plaintext
![]() |
The Java Language Specification recommends listing modifiers in the following order:
|
||
|
|
||
|
1. Annotations
|
||
|
2. public
|
||
|
3. protected
|
||
|
4. private
|
||
|
5. abstract
|
||
|
6. static
|
||
|
7. final
|
||
|
8. transient
|
||
|
9. volatile
|
||
|
10. synchronized
|
||
|
11. native
|
||
|
12. strictfp
|
||
|
|
||
|
Not following this convention has no technical impact, but will reduce the code's readability because most developers are used to the standard order.
|
||
|
|
||
|
== Noncompliant Code Example
|
||
|
|
||
|
----
|
||
|
static public void main(String[] args) { // Noncompliant
|
||
|
}
|
||
|
----
|
||
|
|
||
|
== Compliant Solution
|
||
|
|
||
|
----
|
||
|
public static void main(String[] args) { // Compliant
|
||
|
}
|
||
|
----
|