import java.util.ArrayList;출력:
import java.util.Collections;
import java.util.Hashtable을 사용합니다.
import java.util.List;
import java.util.Map;
public class TriTreeMap {
public static void main(String[] args) {
//해시 테이블 생성
Hashtableht = new Hashtable ();
//키-값 쌍 추가
ht.put("d", "fourth");
ht.put("a", "첫 번째");
ht.put("c", "세 번째");
ht.put("e", "다섯번째");
ht.put("b", "초");
System.out.println("정렬하기 전에:");
for (Map.Entryentry : ht.entrySet())
{
System.out.println(entry.getKey());
}
//hashtable
Listlistcles = new ArrayList (ht.keySet());
//정렬 arraylist
Collections.sort(listcles);
System.out.println("정렬 후:");
for(문자열 키:listcles)
System.out.println(cle);
}
}
정렬 전:
b
a
e
d
c
정렬 후:
a
b
c
d
e
Please disable your ad blocker and refresh the window to use this website.