final static 和 static final 的区别 [英] Difference between final static and static final
问题描述
我发现了一个代码,它声明了这样的代码
I found a code where it declared code like
private final static String API_RTN_SUCCESS = "0";
private final static String API_RTN_ERROR = "1";
public static final String SHARED_PREFERENCE_CONFIG = "shared_preference_config";
public static final String STARTUP_SETTING_KEY = "startup_setting";
它们之间有什么区别或相同吗?或者 private
或 public
有什么不同?
What is the difference between them or are they same? Or does it differ for private
or public
?
推荐答案
完全没有区别.根据8.3.1 - 类 - 字段Java 语言规范的修改器、
如果两个或多个(不同的)字段修饰符出现在一个字段声明中,通常(尽管不是必需的)它们的出现顺序与上面 FieldModifier 产生式中所示的顺序一致.
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.
对于字段,上述产生式按以下顺序列出修饰符:
For fields, the said production lists the modifiers in this order:
@Annotation
public
protected
private
static
final
code> transient
volatile
@Annotation
public
protected
private
static
final
transient
volatile
对于方法:
@Annotation
public
protected
private
abstract
static
code> final
synchronized
native
strictfp
@Annotation
public
protected
private
abstract
static
final
synchronized
native
strictfp
这篇关于final static 和 static final 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!