whenever we want to have some control over the number of objects to be created for a class.
in such cases we create a private constructor, and static method in that class. and we call the private constructor from that static method. we can have count of objects created for that class using a static variable.
Pattern p = Patten.compile("\\d"); Pattern p = Patten.compile("[a-s]"); here the patten object is created by the Pattern class, based on the given input..
do we use these factory methods only when we want to limit the maximum no of objects that can be created or is there any other use of these methods as well ??