java.util.TreeSet 클래스 – 예제
import java.awt.*; import
java.util.*;
public class TreeSetTest implements Comparator {
Set
treeset;
public TreeSetTest() {
treeset = new TreeSet(this);
}
public void test() {
for(int i=0;i<5;i++) {
treeset.add(new
Integer(i));
}
System.out.println("Sert Result : "+treeset);
}
public int compare(Object o1, Object o2) {
return
((Integer)o1).compareTo(o2);
}
public static void main(String[] args) {
TreeSetTest tst = new TreeSetTest();
tst.test();
}
}
댓글 없음:
댓글 쓰기