How to iterate hashmap in reverse order in Java

后端 未结 12 1162
别那么骄傲
别那么骄傲 2020-12-30 01:08

I am trying this for some hour but not finding any best approach to achieve iteration of hashmap in reverse order, this is the hashmap I have.

      Map

        
12条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-30 01:53

    But treemap also gives in asecding order, what i want is in descending order.

    Implement a Comparator that will compare it reverse than natural order and then just iterate normally you will have reverse iteration

提交回复
热议问题