Java中HashMap的基本用法

来源:互联网 发布:淘宝追加评价怎么看 编辑:程序博客网 时间:2024/05/17 03:25
import java.util.HashMap;/** * Created by lx on 2016/10/15. */public class HashMapTest {    public static void main(String[] args) {        HashMap<String ,Student> hashMap=new HashMap<String, Student>();        hashMap.put("1",new Student(001,"Jack"));        hashMap.put("2",new Student(002,"Amy"));        for(String key:hashMap.keySet()){            System.out.println(hashMap.get(key).id);        }    }}
0 0
原创粉丝点击