java - 'public static' 和 'static public' 之间的区别

标签 java coding-style modifiers

在 Java 中,我发现一些开发人员这样写:

public static functionName() {}

但其他一些人写道:

static public functionName() {}

这两者有什么区别?

最佳答案

来自Java Language Specification, section 8.4.3 :

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

因此它们可以以任何顺序出现,但有一个推荐 订购。顺序是:

Annotation public protected private abstract static final synchronized native strictfp

关于java - 'public static' 和 'static public' 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17258697/

相关文章:

JavaScript 代码约定 - 对象声明

Java常量和静态修饰符

java - 键绑定(bind)中的修饰符(SHIFT +(随机键))

c++ - 错误 C2270 : Modifiers not allowed on nonmember functions

java - CPU使用率峰值玩框架java mysql

Java 从 ZipInputStream 条目创建 InputStream

Java 找不到我的 main

java - 处理后退按钮

java - 数据传输对象中的公共(public)字段

Javascript:配置模式