java hashmap key iteration

前端 未结 7 684
谎友^
谎友^ 2020-12-29 06:46

Is there any way to iterate through a java Hashmap and print out all the values for every key that is a part of the Hashmap?

7条回答
  •  萌比男神i
    2020-12-29 07:15

    hashmap.keySet().iterator()
    

    use a for loop to iterate it.

    then use hashmap.get(item) to get individual values,

    Alternatively just use entrySet() for getting an iterator for values.

提交回复
热议问题