I want to limit the no. of direct instance of a class( in Java) say to n, i.e. at any time, not more than n direct objects of the class exist in the memory. But there is no such limit on the no. of indirect objects, such as of any subclass of this class. Is there a way to achieve this in Java?
Share
You can do: