java comparator, how to sort by integer?

后端 未结 6 1010
一整个雨季
一整个雨季 2020-12-08 09:36

Im trying to learn comparator in java and I have found this great example online, my question is how would this code be changed so that the pet names are ordered by age and

6条回答
  •  醉酒成梦
    2020-12-08 09:55

    From Java 8 you can use :

    Comparator.comparingInt(Dog::getDogAge).reversed();
    

提交回复
热议问题