Error Unchecked call to 'put(K, V)' as a member of raw type 'java.util.HashMap'

38,353

Solution 1

Looks like you are missing the types.

Something like

new HashMap<Type1,Type2>().put(K,V)

should work.

Solution 2

For anonymous use:

new HashMap<Type1,Type2>().put(K,V);

For initializing a variable:

HashMap<Type1,Type2> hashMap = new HashMap<>();
hashMap.put(K,V);
Share:
38,353
user3297875
Author by

user3297875

Updated on November 19, 2020

Comments

  • user3297875
    user3297875 over 3 years

    I am getting the error:

    Unchecked call to 'put(K, V)' as a member of raw type 'java.util.HashMap'
    

    This is the line that shows the error:

    JSONArray FieldValues = new JSONArray(new JSONObject(new HashMap().put(K, V)));
    

    Am I doing anything wrong or is there something I should add? any help is greatly appreciated