rspec/rules/S1124/java/rule.adoc

44 lines
590 B
Plaintext
Raw Normal View History

2020-06-30 12:47:33 +02:00
The Java Language Specification recommends listing modifiers in the following order:
2021-02-02 15:02:10 +01:00
2020-06-30 12:47:33 +02:00
1. Annotations
2021-02-02 15:02:10 +01:00
2020-06-30 12:47:33 +02:00
2. public
2021-02-02 15:02:10 +01:00
2020-06-30 12:47:33 +02:00
3. protected
2021-02-02 15:02:10 +01:00
2020-06-30 12:47:33 +02:00
4. private
2021-02-02 15:02:10 +01:00
2020-06-30 12:47:33 +02:00
5. abstract
2021-02-02 15:02:10 +01:00
2020-06-30 12:47:33 +02:00
6. static
2021-02-02 15:02:10 +01:00
2020-06-30 12:47:33 +02:00
7. final
2021-02-02 15:02:10 +01:00
2020-06-30 12:47:33 +02:00
8. transient
2021-02-02 15:02:10 +01:00
2020-06-30 12:47:33 +02:00
9. volatile
2021-02-02 15:02:10 +01:00
2020-06-30 12:47:33 +02:00
10. synchronized
2021-02-02 15:02:10 +01:00
2020-06-30 12:47:33 +02:00
11. native
2021-02-02 15:02:10 +01:00
2020-06-30 12:47:33 +02:00
12. strictfp
2021-02-02 15:02:10 +01:00
2020-06-30 12:47:33 +02:00
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
}
----