Is the order of values retrieved from a HashMap the insertion order

前端 未结 6 1997
天命终不由人
天命终不由人 2020-11-22 07:26

I am trying figure out the order in which the values in a HashMap are/can be retrieved. Heres the code snippet for the same.

import java.util.HashMap;

publ         


        
6条回答
  •  孤城傲影
    2020-11-22 08:23

    A LinkedHashMap is what you're after. From the doco, it differs from HashMap in that it maintains a doubly-linked list running through all of its entries

提交回复
热议问题