EffecitveJava_尽量使用静态内部类

<p class="MsoNormal" style=""><span style="" lang="EN-US"><span style=""><span style="font-family: Times New Roman;"><span style="font-size: small;">1.</span><span style='font: 7pt "Times New Roman";'> </span></span></span></span><span style="font-size: small;"><span style="">嵌套类:是指被定义在另一个类的内部的类。嵌套类存在的目的应该只是为它的外围类提供服务。嵌套类一共分为四种:</span><span lang="EN-US"><span style="font-family: Times New Roman;">static member class;nonstatic member class;anonymourse class</span></span></span></p>
<p class="MsoNormal" style=""><span style="" lang="EN-US"><span style=""><span style="font-family: Times New Roman;"><span style="font-size: small;">2.</span><span style='font: 7pt "Times New Roman";'> </span></span></span></span><span style="font-size: small;"><span style="">如果嵌套类不需要访问外围类的资源,则应该将其设置为</span><span lang="EN-US"><span style="font-family: Times New Roman;">static</span></span><span style="">。</span></span></p>
<p class="MsoNormal" style=""><span style="" lang="EN-US"><span style=""><span style="font-family: Times New Roman;"><span style="font-size: small;">3.</span><span style='font: 7pt "Times New Roman";'> </span></span></span></span><span style="font-size: small;"><span style="">如果没有外围类的情况下也要建立一个嵌套类的实例,则应该将其设置为</span><span lang="EN-US"><span style="font-family: Times New Roman;">static</span></span></span></p>

你可能感兴趣的:(静态内部类)