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.
SAMPLE:
public class Example
{
private Example()
{
}
private static Example obj[3];
Static int i=0;
public static Example getInstance()
{
if((i<3)&&(obj[i]==null))
{
obj[i]=new Example();
return obj[i++];
}
else{
if(i==3)
i--;
return obj[i];
}
}