What is difference between public static
and static public
?
For example :
static public class MyClass....
Or
public static class MyClass....
While there's no difference in terms of functionality (byte code will be exactly the same) you do want to follow conventions, visit the JLS - 8.3.1. Field Modifiers:
FieldModifiers:
FieldModifier
FieldModifiers FieldModifier
FieldModifier: one of
Annotation public protected private
static final transient volatile
It'll be weird to see static public
..
I also recommend you to visit checkstyle.
Edit:
Link from the same page to the class
section:
http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.1.1
JLS 8.1.1 :
A class declaration may include class modifiers.
ClassModifiers: ClassModifier ClassModifiers ClassModifier
ClassModifier: one of Annotation public protected private
abstract static final strictfpIf two or more (distinct) class modifiers appear in a class declaration, then it is customary, though not required, that they appear in the order consistent with that shown above in the production for ClassModifier.
So, public static
is preferred, but the order doesn't really matter.
There is no difference, but dare I say that the de facto standard is public static
. More importantly, be consistent throughout your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With