Java – when using HashMap, the values and keys are guaranteed to be in the same order during iteration?

When I iterate over values or keys, are they related? Map the second key graph to the second value?

Solution

No, not necessarily. You should really use entryset() iterator(). Using this iterator, you will traverse all the maps in the map Entry object and can access each key and associated 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
分享
二维码
< <上一篇
下一篇>>