我的问题很简单:
编译器是否将最终类中的所有方法都视为 final方法?给final类的方法加上final
关键字有什么作用吗?
我知道 final 方法有更好的内联机会,这就是我问的原因。
提前致谢。
最佳答案
你是对的,final 类中的所有方法都是隐式 final 的。
"Note that you can also declare an entire class final. A class that is declared final cannot be subclassed. This is particularly useful, for example, when creating an immutable class like the String class."
All methods in a final class are implicitly final.
关于java - 最终类中的非 final方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8766476/