Do private constructors only create 1 object? code listed
////////////////////////////////////////////
class Hamburger {
private Hamburger() { } // private constructor
//( only 1 object spawned ? ? )
// with public constructors infinite number of objects possible.
static Hamburger makeAHamburger(
{ // static methods do not need objects !
return new Hamburger();
}
}
public class CheeseBurger {
public static void main(
String argv[]) {
// ! Hamburger x = new Hamburger();
// cannot make object directly
Hamburger x = Hamburger.makeAHamburger();
// can call static method to create object
}
}