Comparator won't work with Arrays.sort

前端 未结 5 1214
迷失自我
迷失自我 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:35

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

    You are calling a sort() of Arrays class with ArrayList, ArrayList belongs to Collection family not an Array.

    your error will resolved if you use Collectinss.sort()

提交回复
热议问题