Ho can you restrict to creating only 3 objects for a class at any time ?
Komara Reddy
Select an image from your device to upload
A simple approach is to have an array of n (3-5), and have a private constructor in your “singleton” class. Then you will have an instanceOf method, which is the only way to get an object. This method will look to see if the number of created objects is < n, if it is, it creates a new one and returns it