gpt4 book ai didi

java - Java 中具有抽象方法签名的可见性修饰符

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:41:41 25 4
gpt4 key购买 nike

快速提问:

是正确的语法:

public abstract void myMethod();

abstract public void myMethod();

...区别在于关键字 publicabstract 的顺序。

两者都在没有警告的情况下编译,但哪个是正确的语法?

最佳答案

根据 JLS section 8.1.1

ClassModifier: one of
Annotation public protected private
abstract static final strictfp

If two or more 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.

关于java - Java 中具有抽象方法签名的可见性修饰符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9103732/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com