Does entrySet() in a LinkedHashMap also guarantee order?

前端 未结 3 896
Happy的楠姐
Happy的楠姐 2020-12-08 13:03

I am using a linkedHashMap to guarantee order when someone tries to access it. However, when it comes time to iterate over it, does using entrySet() to return key/value pair

3条回答
  •  有刺的猬
    2020-12-08 13:14

    If you're sure no changes will be made during the iteration, then proper ordering with entrySet() is guaranteed, as stated in the API.

提交回复
热议问题