You could add a static counter to the class, and when it reaches the maximum count you can throw an exception in the constructor.
Or you can use a Singleton pattern. It is typically used to restrict the number of objects created by a class to one, but it could be used just as well to restrict the number object created by the class to any other amount.
public class Example
private static Example obj;
Static int i=0;
public static Example getInstance()