Search code examples
javaarraysjsonhashmap

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


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


Solution

  • Looks like you are missing the types.

    Something like

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

    should work.