class term {
String str;
int id;
public term(String str, int id) {
this.str = str;
this.id = id;
}
public String toString() {
return str+" "+id;
}
}
class sterm implements Comparable{
String str;
int id;
public sterm(String str, int id) {
this.str = str;
this.id = id;
}
public int compareTo(Object o) {
return ((sterm)o).id - id;
}
public String toString() {
return str+" "+id;
}
}
//method1: explicit implements Comparator
class termComparator implements Compa......
阅读全文