java - 静态公共(public) boolean 值与公共(public)静态 boolean 值

标签 java android

对方法使用static public booleanpublic static boolean有什么区别?

我刚刚尝试了两者,两者似乎都编译得很好并且具有相同的效果,除非我做错了。哪一个更好,为什么?

最佳答案

绝对没有区别,但就惯例而言,将 public 放在第一位稍微更受欢迎。来自 section 8.4.3 of the Java Language Specification :

MethodModifier: one of

Annotation public protected private abstract
static final synchronized native strictfp

...
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.

关于java - 静态公共(public) boolean 值与公共(public)静态 boolean 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15721115/

相关文章:

java - 错误 : cannot find symbol method setAlpha(float). setAlpha() 不适用于具有偏移量的数组

java - 如何遍历嵌套 java 对象列表?

java - 为什么 JVM 会在每次实例化时一次又一次地加载相同的 (GUI) 类?

java - RunWith(PowerMockRunner.class) 不适用于包注释

android - 2014 年 Phonegap VS 原生 iOS/Android 开发

java - 删除 ListView 项时出现空指针

java - 如何选择一个随机数并保存它?

android - Cordova 无法使用 cordova-plugin-local-notifications 构建

android - 有没有办法阻止 Android OEM 更改我的应用程序中的字体?

android - 当我尝试使用另一个类的信息设置 EditText 时出现 NullpointerException