java - 变量定义中关键字的顺序重要吗?

标签 java final static-variables class-variables

顺序有没有区别:

public static final String = "something";

public final static String = "something";

?

最佳答案

不,虽然 Java Language Specification建议您使用第一个排序:

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.

关于java - 变量定义中关键字的顺序重要吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5584238/

相关文章:

java - 为什么方法内部大量使用final关键字,尽管不将它们定义为final是完全可以的

java - 为什么我不能在 Java 构造函数中声明静态变量?

c - 你如何在 C 中指定变量是最终的?

java - java 类的最终字段是否应该始终是静态的?

c - C99中局部静态数组的线程安全

java - 通过访问 Class 对象中的静态变量来确定选择哪个子类

java - 实用程序类的静态成员(null)生命周期

c# - 无法以与 C# 相同的格式为 WCF 服务传递 java 参数

java - wso2esb-4.8.0 服务器启动时出错

java - 将原数组中的值替换为新数组