java - How to put value in HashMap? -
this question has answer here:
- how initialize array in java? 9 answers
 
i have map
map<string,string[]> data = hashmap<string,string[]>();   and want put value in it.
"key":["value1","value2"]   i try error:
data.put("key",["value1","value2"]);//syntax error      
you try using array initializer fixed size string arrays following
    map<string, string[]> data = new hashmap<>();     data.put("key", new string[]{"val1", "val2"});   this should work
Comments
Post a Comment