This is my current code:
import java.util.ArrayList;
public class SingletonAList<T> {
private final ArrayList<T> aL = new ArrayList<T>();
SingletonAList() {}
public ArrayList<T> getList(T t) {
return aL;
}
}
What I am looking to do is have it return a Singleton List of the type if it exists; if not to create a new one of type T;
so example three getList calls are made;
getList(Obj1);
getList(Obj2);
getList(Obj1);
On first getList a new ArrayList<Obj1> would be created;
on second getList a new ArrayList<Obj2> would be created;
and on third getList the same arrayList from the first call would be returned.
Any implementation suggestions? I have been messing around...it seems that the new call must be in the getList call; and possibly another list of Types that have already been instantiated?