in java, what is wrong with this assignment:
Map<String, Object> mObj = new HashMap<String, String[]>();
I get:
error: incompatible types: HashMap<String,String[]> cannot be converted to Map<String,Object>
Since String[]
is an Object
, that should work.
If I cast to an unparameterized Map
like this: Map<String, Object> mObj = (Map) new HashMap<String, String[]>();
, it is working but of course, I get a warning and it is dirty.
Further more, I feel that my first assignment should work.
Thank you !
PS: I cannot simply change new HashMap<String, String[]>();
to new HashMap<String, Object>();
because in reality, I call a method that returns a Map<String, String[]>();
and of course, I cannot change this method. Thank you again.