How do I restrict object creation not more than 3 in Java class?
Can you give me an idea of how I can to do it?
Factory pattern is the way to go. Or a static counter can be used. Need to careful about thread safety.