effective-java学习笔记(2)避免在程序中创建重复的对象

尽量避免在程序中创建重复的对象

可以用举个简单的例子

class test{                                                   替换写法       class test{

                                                                                                   private static classA a=new classA();

      void pri(){                                                                             void pri(){

         classA a=new classA ();                                                       a.pri();

          a.pri();

     }                                                                                             }

}                                                                                           }

这样保证程序创建相同对象一次

阅读更多
文章标签: class
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭