Hashtable案例

package tushu;

import java.util.Hashtable;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public class TestHashtable {

    public static void main(String[] args) {
    Map<Integer,String>map=new Hashtable<Integer,String>();
    //键和值都不能为空
        map.put(1, "andy");
        map.put(2, "james");
        map.put(3, "jobs");
    
Set <Entry<Integer,String>>set=map.entrySet();        
    for(Entry<Integer,String> e:set){
        System.out.println(e);
    }
    }

}

 

posted @ 2017-05-10 09:33  苏轼的红烧肉  阅读(135)  评论(0编辑  收藏  举报