如何处理未检查的强制转换警告?
类型安全性:未选中的从对象到HashMap的强制转换
HashMap<String, String> getItems(javax.servlet.http.HttpSession session) {
HashMap<String, String> theHash = (HashMap<String, String>)session.getAttribute("attributeKey");
return theHash;}@SuppressWarnings("unchecked")
HashMap getItems(javax.servlet.http.HttpSession session) {
HashMap theHash = (HashMap)session.getAttribute("attributeKey");
return theHash;}HashMap items = getItems(session);items.put("this", "that");Type safety: The method put(Object, Object) belongs to the raw type HashMap.
References to generic type HashMap<K,V> should be parameterized.沧海一幻觉
慕婉清6462132
相关分类