import java.util.Iterator;Runtime:
import java.util.TreeSet;
public class TreePath {
public static void main(String[] args) {
// TreeSet
TreeSettset = new TreeSet ();
// 트리에 요소 추가 set
tset.add(11);
tset.add(5);
tset.add(6);
tset.add(2);
tset.add(1);
// 오름차순으로 이터레이터 객체를 만듭니다
이터레이터 iterator = tset.iterator();
// TreeSet의 데이터 표시
System.out.println("트리셋 "+
"의 요소를 오름차순으로 정렬: ");
while (반복자.hasNext()){
System.out.println(반복자.다음());
}
}
}
Treeset 요소를 오름차순으로 정렬:
1
2
5
6
11
Please disable your ad blocker and refresh the window to use this website.