Hi guys,
I have been trying to develope a generic singleton pattern and run into a few problems. I have read the previous form comments and I'm still a little confused.
I have the following piece of code:
private static Hashtable<Class<T>,T> instances = new Hashtable<Class<T>,T>();
protected Factory(){}
public static <T> T getInstance(Class<T> cls)
{
T result = null;
if(instances.containsKey(cls))
{
}
return result;
}
However I know this doesn't work as I can't create a static Object with a generic? I was wondering if someone could show me how it should be done? And maybe post some code ?
David