Given:
class Vehicle implements Comparable
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
vehicles.add(new Vehicle (10123, ''Ford''));
vehicles.add(new Vehicle (10124, ''BMW''));
System.out.println(vehicles);
What is the result?
Currently there are no comments in this discussion, be the first to comment!