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:
- annotations
- type parameters
- access modifiers
static
final
transient
(only fields)volatile
(only variables)synchronized
(only methods)
i never used strictfp
or native
, think put them around synchronized
.
Comments
Post a Comment