Java – extract values from HashMap
•
Java
I try to learn and understand through the work of HashMap So I created this HashMap to store some values that will give output when displayed using the iterator
1=2 2=3 3=4
wait. I use iterator The next () function gets this output Now what I really doubt is that, due to the type of the value returned by the iterator object, if I only need to extract the right value of the above equivalent, what is the function? Something like a string Is there any way I can get the results
2 3 4
Any help would be appreciated Thank you in advance
Solution
I'll use something like that
Map<Integer,Integer> map = new HashMap<>(); for(int value: map.values()) System.out.println(value);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码