I have a code with a class name Car.
public class Car{
    private String carName;
    private String carDesc;
    private int quantity;
    public String getCarName() {
        return carName;
    }
    public void setCarName(String carName) {
        this.carName = carName;
    }
    public String getCarDesc() {
        return carDesc;
    }
    public void setCarDesc(String carDesc) {
        this.carDesc = carDesc;
    }
    public int getQuantity() {
        return quantity;
    }
    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }
}
Now, using the for loop,  I am creating a creating a list of class “Car”.
List<Car>  cars= new ArrayList<Car>();
Car car;
for(int i=0;i<100;i++)
{
   car= new car();
   car.setname(...);
   cars.add(car);
}
My list contains a few car names added to it.
Can someone help me in sorting this arrayList based on the car names of each object in the list?