Java Hashtable 哈希表

Java Hashtable 哈希表

package com.ssm.cts.test;

import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Stack;
import java.util.Vector;

public class ClassTest {
    // 测试
  public static void main(String[] args) {
    
    Hashtable<String, String> ht = new Hashtable<String, String>();
    Enumeration<String> name;
    String str;
    
    ht.put("jiang", "9001");
    ht.put("zhi", "9002");
    ht.put("hao", "9003");

    name = ht.keys();
    while (name.hasMoreElements()) {
      str = (String) name.nextElement();
      System.out.println(str + ": " + ht.get(str));
    }
    
    System.out.println("jiang: " + ht.get("jiang"));
  }
}

 

发表回复

您的电子邮箱地址不会被公开。