呵呵,设成private的就不能用new 来生成实例了,要自己写一个public的方法来生成实例.在设计模式中singleton模式就有一种方法是采用这种方式来确保只生成这个类的一个实例.

解决方案 »

  1.   

    当private用来限制类时,包外是不可能调用的,只能在包内调用。
    目的:该类要处理一些比较敏感的数据,或者只是在某个包内要用。
      

  2.   

    You can call the private constructor by a non-private constructor, so in this condition, the private constructor maybe a full-parameterized service constructor, that means you can not directly use this constuctor to get an instance, but you can use it to assisit other constructors. This can prevent your client-programmer from using the crucial private constructor directly.
    This technique is very common and easy, but not used very much in practice.
      

  3.   

    设成private以后也能用,和普通的private方法一样只能在其内部访问。
    不知道将constuctor设为private有多大的实际意义?另外,应该是Aaa a=new Aaa();  呵呵