Java 修饰符顺序 the sequential order of the modifiers

  

 

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
}
————————————————
版权声明:本文为CSDN博主「Mr_YDK」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/ydk888888/article/details/80288930

posted @ 2021-07-07 10:24  ascertain  阅读(64)  评论(0编辑  收藏  举报