public class Drink implements Comparable{
public String name;
public int compareTo(Object o){
return 0;
}and:Drink one=new Drink();
Drink two=new Drink();
one.name="Coffee";
two.name="Tea";
TreeSet set=new TreeSet();
set.add(one);
set.add(two);A programmer iterates over the TreeSet and prints the name of each Drink object.what is the rusult?A Tea
B.Coffe
C.Coffe
Tea
D.Compilation fails.
E.the code runs with no output
F.An exception is thrown at runtime
public String name;
public int compareTo(Object o){
return 0;
}and:Drink one=new Drink();
Drink two=new Drink();
one.name="Coffee";
two.name="Tea";
TreeSet set=new TreeSet();
set.add(one);
set.add(two);A programmer iterates over the TreeSet and prints the name of each Drink object.what is the rusult?A Tea
B.Coffe
C.Coffe
Tea
D.Compilation fails.
E.the code runs with no output
F.An exception is thrown at runtime
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货