Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 390
user3297875 Avatar asked Aug 01 '14 16:08

user3297875


2 Answers

Looks like you are missing the types.

Something like

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

should work.

like image 71
bob0the0mighty Avatar answered Nov 05 '22 17:11

bob0the0mighty


For anonymous use:

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

For initializing a variable:

HashMap<Type1,Type2> hashMap = new HashMap<>();
hashMap.put(K,V);
like image 24
Chintan Shah Avatar answered Nov 05 '22 16:11

Chintan Shah