LoginSignup
27
13

More than 3 years have passed since last update.

Java のメソッド修飾子(method modifiers) の順番は決まっている

Last updated at Posted at 2016-12-23

Java の method modifiers の順番

Java のメソッド修飾子(method modifiers) の順番は一応決まっています。

Annotation public protected private
abstract static final synchronized native strictfp

の順で書くのが習慣上よいそうです。

public static final
× public final static

public abstract
× abstract public

言語仕様に書いてある

なんとJavaの言語仕様にかいてありました。
言語仕様のなかでコーディングスタイルにまで言及するんですね。意外でした。

If two or more (distinct) method modifiers appear in a method declaration, it is customary, though not required, that they appear in the order consistent with that shown above in the production for MethodModifier.

The Java® Language Specification - Java SE 12 Edition
https://docs.oracle.com/javase/specs/jls/se12/html/jls-8.html#jls-8.4.3

参考

27
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
27
13