Java: how to convert HashMap to array

前端 未结 12 1957
时光取名叫无心
时光取名叫无心 2020-11-29 16:36

I need to convert a HashMap to an array; could anyone show me how it\'s done?

12条回答
  •  时光说笑
    2020-11-29 16:57

    I used almost the same as @kmccoy, but instead of a keySet() I did this

    hashMap.values().toArray(new MyObject[0]);
    

提交回复
热议问题