package sample;
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Random r = new Random();
        ArrayList<Car> a = new ArrayList<Car>();
        ArrayList<Integer> p = new ArrayList<Integer>(Arrays.asList(1000, 100, 3456, 123, 678));
        ArrayList<String> c = new ArrayList<String>(Arrays.asList("white", "black", "purple", "pink", "green"));
        for (int i = 0; i < 5; i++) {
            a.add(new Car(c.get(r.nextInt(5)), p.get(r.nextInt(5))));
        }
        Car car = new Car("", 0);
        for (int i = 0; i < a.size(); i++) {
            if (a.get(i).getPrice() > car.getPrice())
               car.getPrice() = a.get(i).getPrice();
        }
    }
}
package sample;
public class Car {
    private int price;
    private String color;
    public Car(String color, int price) {
        this.price = price;
        this.color = color;
    }
    public int getPrice() {
        return price;
    }
    public void setPrice(int price) {
        this.price = price;
    }
    public String getColor() {
        return color;
    }
    public void setColor(String color) {
        this.color = color;
    }
    
    public String toString() {
        return "Color " + getColor() + " Price " + getPrice();
    }
}