Question 1 of 5
Crate is a student-defined class with getter getWeight. Write lightest so it returns the smallest weight in crates. Assume crates is not empty. Use ArrayList methods size and get only.
public class Crate {
private int weight;
private String label;
public Crate(int weight, String label) {
this.weight = weight;
this.label = label;
}
public int getWeight() {
return weight;
}
public String getLabel() {
return label;
}
}
public int lightest(ArrayList<Crate> crates) {
/* write this method */
}