public class SortHashtable {
public static void main(String[] args) {
// Create and populate hashtable
Hashtable ht = new Hashtable();
ht.put("ABC", "abc");
ht.put("XYZ", "xyz");
ht.put("MNO", "mno");
// Sort hashtable.
Vector v = new Vector(ht.keySet());
Collections.sort(v);
// Display (sorted) hashtable.
for (Enumeration e = v.elements(); e.hasMoreElements();) {
String key = (String)e.nextElement();
String val = (String)ht.get(key);
System.out.println("Key: " + key + " Val: " + val);
}
}
}
public static void main(String[] args) {
// Create and populate hashtable
Hashtable ht = new Hashtable();
ht.put("ABC", "abc");
ht.put("XYZ", "xyz");
ht.put("MNO", "mno");
// Sort hashtable.
Vector v = new Vector(ht.keySet());
Collections.sort(v);
// Display (sorted) hashtable.
for (Enumeration e = v.elements(); e.hasMoreElements();) {
String key = (String)e.nextElement();
String val = (String)ht.get(key);
System.out.println("Key: " + key + " Val: " + val);
}
}
}
이런것은 찾으려 들면 찾기 어렵습니다.