so I'm trying to sort my arraylist of geometric objects in ascending order (by area). However, I'm running into an error
The method add(GeometricObject) in the type ArrayList<GeometricObject> is not applicable for the arguments (double)
in my code block
private static void selectionSort(ArrayList<GeometricObject> list) {
for (int i = 0; i < list.size(); i++) {
if (i < list.size() - 1) {
if (list.get(i).getArea() > list.get(i + 1).getArea()) {
double j = list.get(i).getArea();
list.remove(i);
list.add(i, list.get(i));
list.remove(i + 1);
list.add(j).getArea();
i = -1;
}
}
}
}
line
list.add(j).getArea();
Again, I'm just trying to sort them in order of their areas so i can later print the array. Any help or pointers in the right direction would be appreciated, thanks!
doubleto aArrayList<GeometricObject>?list.add(i, list.get(i));andlist.add(j).getArea();? doesn't make a lot of sense to me