Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

HashMap and put warnings because unchecked calls...

843793Apr 20 2007 — edited Apr 21 2007
I'm writting an application that connects to some APIs, but when compiling, I get some warning messages:

warning: [unchecked] unchecked call to put(K, V) as a member of the raw type java.util.HashMap

Here is the code:
public class hashMapMgr {

    HashMap hm;

    public hashMapMgr() {
        hm = new HashMap;
        hm.clear();
    }

    public void addKey(String key, String value) throws myException {
        Object status;
        if (key.length()==0 && value.length()==0) {
            throws new myException ("Error");
        }
        status = hm.put(key,value);
    }

    public HashMap getMap() {
        return hm;
    }
}
Why am I getting that warning message? Should I use a try..catch to remove the warning message? or should I extend or implement something?

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 19 2007
Added on Apr 20 2007
2 comments
432 views