Java modifiers syntax and format

后端 未结 5 782
梦谈多话
梦谈多话 2020-11-28 14:09

I find myself getting confused as to the order of access and non access modifiers. For example

abstract void go()  
abstract public void go()  
public final          


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-28 14:20

    See http://checkstyle.sourceforge.net/config_modifier.html.

    The correct (or rather, conventional) order is :

    1. public
    2. protected
    3. private
    4. abstract
    5. static
    6. final
    7. transient
    8. volatile
    9. synchronized
    10. native
    11. strictfp

    This order should come naturally to your mind after some days programming in Java.

提交回复
热议问题