java - class attributes declaration, order of the attributes' properties (final, private, static, type) -


i'm trying find documentation on best way order properties of class attribute, such private/protected/public, final, static, type.

i'll post example see mean.

class {    public final static int foo = 3;    final public static int foo = 3;  } 

ok, assume attrbiute type (int, string, char) goes before name of attribute.

my real doubt when try position static, final, , v

the language specification says modifiers must go before type, int comes last. modifiers include type parameters, annotations, access modifiers (private, protected, public), static, final, synchronized, strictfp, volatile, transient , (from "what allows compiler") can come in order.

some days ago did google search , static final more final static, helps ordering them :-)

i think in general order of modifiers common:

  1. annotations
  2. type parameters
  3. access modifiers
  4. static
  5. final
  6. transient (only fields)
  7. volatile (only variables)
  8. synchronized (only methods)

i never used strictfp or native, think put them around synchronized.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -