I am reading the Effective Java by Joshua Bloch and I have question about Item1 Static Factory Method.
Quote[Bloch, p.7]<
Let's say you have an interface called List and you want to use the static factory method to create different type of lists. You cannot define the static factory methods in the List interface because it's an interface. So what you have to do it have a class that return instances of classes that implement List
public class ListFactory{
private ListFactory(){}
public static List makeArrayList(){...}
public static List makeLinkedList(){...}
public static List makeCrazyList(){...}
}
You cannot do this
public interface List{
public static List makeArrayList();
public static List makeLinkedList();
public static List makeCrazyList();
}
Since List is interface.