'Hashtable'에 해당되는 글 2건

  1. 2007.01.23 [sample] Hashtable을 Sort 해서 가져오기
  2. 2007.01.23 [sample] Hashtable key&Value 가져오기 1
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);
        }
     }
}

이런것은 찾으려 들면 찾기 어렵습니다.
Hashtable hsTable = new Hashtable ();

Enumeration e = hsTable.keys();
while(e.hasMoreElements()){
    String sKey = e.nextElement().toString();
    String hsElement = (String)hsTable.get(sKey);
}

매번 짜면서 헷갈린다.
1 

글 보관함

카운터

Total : / Today : / Yesterday :
get rsstistory!