Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the order of keywords in variable definition matter?

Is there any difference between the order:

public static final String = "something";

or

public final static String = "something";

?

like image 630
Rihards Avatar asked Apr 07 '11 16:04

Rihards


2 Answers

No, although the Java Language Specification recommends that you use the first ordering:

FieldModifiers:
  FieldModifier
  FieldModifiers FieldModifier

FieldModifier: one of
  Annotation public protected private
  static final transient volatile

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

like image 67
Charles Hellstrom Avatar answered Sep 22 '22 14:09

Charles Hellstrom


No - there is no difference betweeen the two.

From section 8.3.1 of the Java 2 Language Specification:

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

like image 7
Amir Afghani Avatar answered Sep 20 '22 14:09

Amir Afghani