Given:
class Vehicle implements Comparable<Vehicle>{
int vno;
String name;
public Vehicle (int vno, String name) {
this.vno = vno,;
this.name = name;
}
public String toString () {
return vno + ":" + name;
}
public int compareTo(Vehicle o) {
return this.name.compareTo(o.name);
}
and this code fragment:
Set<Vehicle> vehicles = new TreeSet <> ();
vehicles.add(new Vehicle (10123, "Ford"));
vehicles.add(new Vehicle (10124, "BMW"));
System.out.println(vehicles);
What is the result?
jduarte
Highly Voted 3 years, 11 months agoasdfjhfgjuaDCV
Most Recent 9 months, 2 weeks agosteefaand
10 months, 3 weeks agoduydn
1 year, 3 months ago_Ismail_
2 years, 7 months agosamtash1034
2 years, 11 months agoSvetleto13
3 years, 7 months ago