Comparator won't work with Arrays.sort

前端 未结 5 1217
迷失自我
迷失自我 2021-01-21 07:03

So I\'m working on a comparator problem and I can\'t figure out why the Array.sort in this first class is giving me the error of:

The method

5条回答
  •  暖寄归人
    2021-01-21 07:25

    Arrays.sort takes an array as its first argument. To sort a collection such as a list, use Collections.sort.

    Collection.sort(elist, new CalorieComparator());
    

    Also, note that your method won't compile because you aren't returning a List.

提交回复
热议问题