public interface Cache<T>{
public void put(String key,T value);
public Object get(Object key);
}
public class CacheImpl<T> implements Cache {
private static Object monitor = new Object();
private static CacheImpl instance;
private Map<String, T> cache = Collections.synchronizedMap(new HashMap<String, T>());
}
在上面的代码中,我必须使用泛型进行类型安全检查,但在实现的类中出现错误。