package Nov2016; import java.util.TreeSet; public class Ques1108 { public static void main(String[] args){ Animal dog = new Animal("dog"); Animal cat = new Animal("cat"); TreeSet<Animal> animals = new TreeSet<Animal>(); animals.add(dog); animals.add(cat); System.out.println(animals); // 1 } } // 動物類 class Animal implements Comparable<Animal>{ private String name; Animal(String name){ this.name = name; } @Override public int compareTo(Animal o){ return 0; } @Override public String toString(){ return name; } }
今日問題:
請問注釋1處輸出結果是什麼?(點擊以下“【Java每日一題】20161108”查看20161107問題解析)
題目原發布於公眾號、簡書:【Java每日一題】20161108,【Java每日一題】20161108
每日一題最新將在公眾號發布,歡迎訂閱,交流進步