I am trying to make a singleton like the following, but I keep getting a warning. If possible, I don't want suppress warning. Is there a way to do it?
For now, I don't want to think about the thread-safety. I just want to pass this warning.
public interface Storage<K, V> {
public void put(K key, V value);
public V get(K key);
}
public static class DefaultStorage<K, V> implements Storage<K, V> {
private Map<Object, Object> map = new ConcurrentHashMap<Object, Object>();
private static DefaultStorage<K, V> defaultStorage;
private DefaultStorage() {
//
}
public static DefaultStorage<?, ?> getInstance() {
if (defaultStorage== null) {
defaultStorage= new DefaultStorage();
}
return defaultStorage;
}
}
Thanks.