Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert a hashmap to an array [duplicate]

I have a hashmap like this:

HashMap<String, String[]> map = new HashMap<String, String[]>();

I want to convert this to an array, say Temp[], containing as first value the key from the hashmap and as second the String[]-array from the map, also as array. Is this possible? How?

like image 540
tetsuya Avatar asked Mar 16 '11 07:03

tetsuya


1 Answers

See same question here:

hashMap.keySet().toArray(); // returns an array of keys
hashMap.values().toArray(); // returns an array of values
like image 105
Benoit Thiery Avatar answered Sep 30 '22 07:09

Benoit Thiery