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, 5 months agoasdfjhfgjuaDCV
Most Recent 4 months, 1 week agosteefaand
5 months, 1 week agoduydn
10 months ago_Ismail_
2 years, 1 month agosamtash1034
2 years, 6 months agoSvetleto13
3 years, 2 months ago