There was a need to get rid of the second compare compare method, however, after its removal, the program is not compiled. Tell me what could be the snag?
public class Car implements Comparator<ArrayList> { private int speed; public int getSpeed() { return speed; } public Car(int speed) { this.speed = speed; } public static void main(String[] args) { Random rand = new Random(); ArrayList<ArrayList<Car>> listsOfCars = new ArrayList<>(); for (int i = 0; i < 35; i++) { int a = rand.nextInt(50); ArrayList<Car> cars = new ArrayList<Car>(); for (int j = 0; j < a; j++) { cars.add(new Car(a)); } listsOfCars.add(cars); } Collections.sort(listsOfCars, SizeComparator); for (ArrayList<Car> cars : listsOfCars) { System.out.println(cars.size()); } } public static Comparator<ArrayList> SizeComparator = new Comparator<ArrayList>() { @Override public int compare(ArrayList arrlist1, ArrayList arrlist2) { return arrlist1.size() - arrlist2.size(); } }; @Override public int compare(ArrayList arrlist1, ArrayList arrlist2) { return 0; } }