hashtableの使い方

2225 ワード

 1 import java.util.Hashtable;

 2 public class HashTable {

 3 public static void main (String[] args)

 4 {

 5     Hashtable<String,Object> ht=new Hashtable<String,Object>();

 6     ht.put("xiao wang", 30);

 7     ht.put("zhang san", "aaa");

 8     ht.put("he hai", true);

 9     

10     System.out.println(ht.size());

11     ht.remove("zhang san");

12     System.out.println(ht.size());

13     

14     

15     System.out.println(ht.get("he hai"));

16      ht.put("he hai", "hello");

17      System.out.println(ht.get("he hai"));

18 }

19 }