How to sort an ArrayList with object using stream().sorted()

前端 未结 5 1593

I am having real trouble with using stream and sorted to sort my ArrayList and hope someone can help out. The code uses Croatian words, but I don\'t think that will be a pro

5条回答
  •  礼貌的吻别
    2021-01-13 09:05

    Below code is used for to sort the your Publikacija object type Arraylist on behalf of "getCijena"

    ' Collections.sort(data, new Comparator() {
                public int compare(Publ`enter code here`ikacija s1, Publikacija s2) {
    
                    return s1.getCijena.compareTo(s2.getCijena);
                }
            });'
    

提交回复
热议问题