<legend id='0ecaF'><style id='0ecaF'><dir id='0ecaF'><q id='0ecaF'></q></dir></style></legend>

    • <bdo id='0ecaF'></bdo><ul id='0ecaF'></ul>

    <i id='0ecaF'><tr id='0ecaF'><dt id='0ecaF'><q id='0ecaF'><span id='0ecaF'><b id='0ecaF'><form id='0ecaF'><ins id='0ecaF'></ins><ul id='0ecaF'></ul><sub id='0ecaF'></sub></form><legend id='0ecaF'></legend><bdo id='0ecaF'><pre id='0ecaF'><center id='0ecaF'></center></pre></bdo></b><th id='0ecaF'></th></span></q></dt></tr></i><div id='0ecaF'><tfoot id='0ecaF'></tfoot><dl id='0ecaF'><fieldset id='0ecaF'></fieldset></dl></div>
  1. <small id='0ecaF'></small><noframes id='0ecaF'>

      <tfoot id='0ecaF'></tfoot>
    1. 最终类中的非最终方法

      Non-final methods in a final class(最终类中的非最终方法)
      • <i id='7I050'><tr id='7I050'><dt id='7I050'><q id='7I050'><span id='7I050'><b id='7I050'><form id='7I050'><ins id='7I050'></ins><ul id='7I050'></ul><sub id='7I050'></sub></form><legend id='7I050'></legend><bdo id='7I050'><pre id='7I050'><center id='7I050'></center></pre></bdo></b><th id='7I050'></th></span></q></dt></tr></i><div id='7I050'><tfoot id='7I050'></tfoot><dl id='7I050'><fieldset id='7I050'></fieldset></dl></div>
        <tfoot id='7I050'></tfoot>

          1. <legend id='7I050'><style id='7I050'><dir id='7I050'><q id='7I050'></q></dir></style></legend>

            <small id='7I050'></small><noframes id='7I050'>

                <tbody id='7I050'></tbody>
                <bdo id='7I050'></bdo><ul id='7I050'></ul>
                本文介绍了最终类中的非最终方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我的问题很简单:
                编译器是否将最终类中的所有方法都视为最终方法?给final类的方法加上final关键字有什么作用吗?

                My question is pretty simple:
                Does the compiler treat all the methods in a final class as being final themselves? Does adding the final keyword to methods in a final class has any effect?

                我知道 final 方法有更好的内联机会,这就是我问的原因.

                I understood that final methods have a better chance of getting inlined and this is why I am asking.

                提前致谢.

                推荐答案

                你说得对,final类中的所有方法都是隐式final的.

                You're correct, all methods in a final class are implicitly final.

                见这里:

                "请注意,您还可以声明整个类 final.声明的 final 不能被子类化.这特别有用,因为例如,在创建像 String 类这样的不可变类时."

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

                这里:

                final 类中的所有方法都是隐式 final.

                All methods in a final class are implicitly final.

                您可能也会感兴趣:Java final 关键字的性能提示

                这篇关于最终类中的非最终方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Compiling C++ for the JVM(为 JVM 编译 C++)
                Compile to java bytecode (without using Java)(编译成java字节码(不使用Java))
                How to drive C#, C++ or Java compiler to compute 1+2+3+...+1000 at compile time?(如何在编译时驱动 C#、C++ 或 Java 编译器计算 1+2+3+...+1000?)
                Java ClassLoader: load same class twice(Java ClassLoader:两次加载相同的类)
                How to debug .class files in ECLIPSE?(如何在 ECLIPSE 中调试 .class 文件?)
                Java quot;The blank final field may not have been initializedquot; Anonymous Interface vs Lambda Expression(Java“可能尚未初始化空白的最终字段匿名接口与 Lambda 表达式)
                <i id='D3D6a'><tr id='D3D6a'><dt id='D3D6a'><q id='D3D6a'><span id='D3D6a'><b id='D3D6a'><form id='D3D6a'><ins id='D3D6a'></ins><ul id='D3D6a'></ul><sub id='D3D6a'></sub></form><legend id='D3D6a'></legend><bdo id='D3D6a'><pre id='D3D6a'><center id='D3D6a'></center></pre></bdo></b><th id='D3D6a'></th></span></q></dt></tr></i><div id='D3D6a'><tfoot id='D3D6a'></tfoot><dl id='D3D6a'><fieldset id='D3D6a'></fieldset></dl></div>
                    <tbody id='D3D6a'></tbody>
                • <small id='D3D6a'></small><noframes id='D3D6a'>

                    <legend id='D3D6a'><style id='D3D6a'><dir id='D3D6a'><q id='D3D6a'></q></dir></style></legend>

                      <bdo id='D3D6a'></bdo><ul id='D3D6a'></ul>
                        1. <tfoot id='D3D6a'></tfoot>