Declaration of class attributes, order of attribute properties (final, closed, static, type)

I am trying to find documentation on how best to access class attribute properties such as private / protected / public, final, static, type.

I will post an example to understand what I mean.

class A {

  public final static int FOO = 3;

  final public static int FOO = 3;

}

Well, I assume that the type attrbiute (int, String, char) precedes the attribute name.

My real doubt is that I'm trying to set static, final and v

+3
source share
5 answers

, , int . , , (, , ), static, final, synchronized, strictfp, volatile, transient ( " ", ) .

google static final , final static, : -)

, :

  • static
  • final
  • transient ( )
  • volatile ( )
  • synchronized ( )

strictfp native, , synchronized.

+7

, checkstyle ModifierOrder check [1] ( ):

, Java, 8.1.1, 8.3.1 8.4.3. :

  • strictfp

[1] http://checkstyle.sourceforge.net/config_modifier.html

+1

:

private/protected/public, static, final, type

0

(, ) . , .

Therefore, if you want to use a fixed order, it is read-only. And your code looks better if you always use the same order in your compilation units.

But again, the order does not affect the byte code. Forget about micro optimization;)

0
source

Source: https://habr.com/ru/post/1793028/


All Articles