JDK5.0怎么去除类型转换的警告?
public static HashMap <String, Object> getMap(String aMap) {
if (sMap.containsKey(aMap)) {
return (HashMap <String, Object> ) sMap.get(aMap);
}
return null;
}
怎么去掉警告信息?
还有destmap.putAll(frommap.getMap(deststr));
------解决方案--------------------public static HashMap <String, Object> getMap(String aMap) {
HashMap <String, HashMap <String, Object> > sMap = new HashMap <String, HashMap <String, Object> > ();
if (sMap.containsKey(aMap)) {
return sMap.get(aMap);
}
return null;
}
这样就可以 HashMap <String, Object>
指定里面放的就是
------解决方案--------------------或者用:
@SuppressWarnings( "unchecked ")
(添加到方法前一行)
也可以
------解决方案--------------------public static HashMap <String, Object> getMap(String aMap) {
if (sMap.containsKey(aMap)) {
return (HashMap <String, Object> ) sMap.get(aMap);
}
return null;
}
sMap还没有声明啊.