Effective java says
"Consider providing static factory methods instead of constructors"
If you have a
class A {
public static A getInstance() {
return new A();
}
}
Does it make sense to provide this method for class A , rather than call new A() in the code.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…