Retrieve all values from HashMap keys in an ArrayList Java

前端 未结 9 1381
野性不改
野性不改 2021-01-31 14:21

Good day, this is kind of confusing me now(brain freeze!) and seem to be missing something. Have an ArrayList which i populate with a HashMap. now i put in my HashMap and arrayl

9条回答
  •  遥遥无期
    2021-01-31 14:57

    Create an ArrayList of String type to hold the values of the map. In its constructor call the method values() of the Map class.

    Map  map;
    List list = new ArrayList(map.values());
    
        

    提交回复
    热议问题