'분류 전체보기'에 해당되는 글 256건

  1. 2007.01.23 [sample] treeMap 사용법 1
  2. 2007.01.23 [sample] HashMap 사용방법
  3. 2007.01.23 [sample] Hashtable을 Sort 해서 가져오기
  4. 2007.01.23 [sample] StringTokenizer 사용법
  5. 2007.01.23 [sample] request 객체 모두 출력하기
  6. 2007.01.23 [sample] Hashtable key&Value 가져오기 1
import java.util.*;

public class Freq {
     private static final Integer ONE = new Integer(1);
     public static void main(String args[]) {
          Map m = new TreeMap();

          // Initialize frequency table from command line
          for (int i=0; i < args.length; i++) {
               Integer freq = (Integer) m.get(args[i]);
               m.put(args[i], (freq==null ? ONE :
               new Integer(freq.intValue() + 1)));
          }
      System.out.println(m.size()+" distinct words detected:");
      System.out.println(m);
    }
}
public static void main(String argv[]) {
     HashMap hm = new HashMap();
     System.out.println(hm.put("aaa", "111"));

     Set set = hm.keySet();
     Object []hmKeys = set.toArray();
     for(int i = 0; i < hmKeys.length; i++)  {
          String key = (String)hmKeys[i];
          System.out.print(key);
          System.out.print(" - ");
          System.out.println((String)hm.get(key));
     }
}

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 class Test {
    public static void main(String[] argv) {
        String data = "(999) 999-9999";

        StringTokenizer t2 = new StringTokenizer(token, "-");
        while (t2.hasMoreTokens()) {
             System.out.println(t2.nextToken());
        }
    }
}

StringTokenizer st = new StringTokenizer(lineStr, " ,\t");
String goodsCode = st.hasMoreTokens() ? (String)st.nextToken().trim() : "*";
String saleDate = st.hasMoreTokens() ? (String)st.nextToken().trim() : "*";

문자열 자르기에 최강자죠^^

Enumeration enum = req.getParameterNames ();
    while (enum.hasMoreElements()) {
        String name = (String) enum.nextElement();
        String values[] = req.getParameterValues(name);
  
        if (values != null) {
            for (int i=0; i< values.length; i++) {
            out.println (name + "( " + i +" )" + values[i]);
        }
    }
}

디버깅이나 parameter 객체를 모두 찾을때 효과적임
Hashtable hsTable = new Hashtable ();

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

매번 짜면서 헷갈린다.
1 ··· 23 24 25 26 

글 보관함

카운터

Total : / Today : / Yesterday :
get rsstistory!