Recommended order of a method's mutiple modifiers

来源:互联网 发布:万网域名转移 编辑:程序博客网 时间:2024/05/19 23:13

 

The method modifiers consist of the following:

 

annotations

 

access modifiers 

 

abstract 

 

static 

 

final: A final method cannot be overridden in a subclass.

 

synchronized: A synchronized method has additional semantics related to the control of concurrent threads within a program.

 

native 

 

strict: floating point A method declared strictfp has all floating-point arithmetic evaluated strictly. If a method is declared within a class declared strictfp, then that method is implicitly declared strictfp. 

 

An abstract method cannot be static, final, synchronized, native, or strict. A native method cannot be strict.

 

When multiple modifiers are applied to the same method declaration, we recommend using the order listed.

 

Reference: 《The Java Language Programming, the Fourth Edition》

 

原创粉丝点击