Java 8 Lambda: Comparator

前端 未结 7 1464
鱼传尺愫
鱼传尺愫 2021-02-01 12:53

I want to sort a list with Lambda:

List messagesByDeviceType = new ArrayList();      
messagesByDeviceType.sort((Message o1, Messag         


        
7条回答
  •  别那么骄傲
    2021-02-01 13:38

    lamda comparator

    In the place of Developer write your class name 
    
        Comparator byName = 
            (Developer o1, Developer o2)->o1.getName().compareTo(o2.getName());
    

提交回复
热议问题