Java: how to convert HashMap to array

前端 未结 12 1954
时光取名叫无心
时光取名叫无心 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 17:13

    HashMap hashMap = new HashMap<>();
    String[] stringValues= new String[hashMap.values().size()];
    hashMap.values().toArray(stringValues);
    

提交回复
热议问题