I use singletons often for some static caches. Now I have a generic class "Cache<K, V>" that I want to subclass and use the singleton pattern:
public final class StaticCache<K, V> extends Cache<K, V> {
static private StaticCache<K, V> instance = null;
}
But the declaration of the variable "instance" fails:
non-static class K cannot be referenced from a static context
non-static class V cannot be referenced from a static context
Of course, I don't want K,V static but only my instance. Is this possible at all?