java - How to put value in HashMap? -


this question has answer here:

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

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -