public class TreeMapDemo { public static void main(String[] args) {TreeMap tr=new TreeMap(new Mycomparator()); tr.put("A", 12); tr.put("B", 13); tr.put("C", 14); tr.put("D", 15); System.out.println(tr); } } class Mycomparator implements Comparator{ @

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/03 03:28:41
public class TreeMapDemo { public static void main(String[] args) {TreeMap tr=new TreeMap(new Mycomparator()); tr.put(
xN1_Ր!xY9ą26mc !^V*F|0%ѥchii5#v*g!%PR' db(@ĸFLݰEN +:Ͳ*tBk;OItsLPhJQ͕ѹ0Ddž|xL DLJ82Ulsțp*}ǂa2?if`!(52h`V*A ) UÃ fXt:">"nSKR5\ oݧVNM4{ZЩlN)Mqz㷟gd8˙دnkW\{Gqt4kIQuE6;i~{KS ܻlx'uEѭ^rj

public class TreeMapDemo { public static void main(String[] args) {TreeMap tr=new TreeMap(new Mycomparator()); tr.put("A", 12); tr.put("B", 13); tr.put("C", 14); tr.put("D", 15); System.out.println(tr); } } class Mycomparator implements Comparator{ @
public class TreeMapDemo { public static void main(String[] args) {
TreeMap tr=new TreeMap(new Mycomparator()); tr.put("A", 12); tr.put("B", 13); tr.put("C", 14); tr.put("D", 15); System.out.println(tr); } } class Mycomparator implements Comparator{ @Override public int compare(Object o,Object oo) { String s1=(String)o; String s2=(String)oo; return s2.compareTo(s1); } } 我问下,这加入 new Mycomparator() 的作用在哪边?我把他删除了.照样可以输出这些数啊!求解

public class TreeMapDemo { public static void main(String[] args) {TreeMap tr=new TreeMap(new Mycomparator()); tr.put("A", 12); tr.put("B", 13); tr.put("C", 14); tr.put("D", 15); System.out.println(tr); } } class Mycomparator implements Comparator{ @
比较器 多用来排序