33.Map
Posted luzhanshi
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了33.Map相关的知识,希望对你有一定的参考价值。
1.概述
2.Map的获取功能
3.遍历
方式1:
HashMap<String, String> hashMap = new HashMap<>(); hashMap.put("001","张飞"); hashMap.put("002","关于"); hashMap.put("003","赵云"); Set<String> stringSet = hashMap.keySet(); for (String key:stringSet){ System.out.println(key+":"+hashMap.get(key)); }
方式2:
Set<Map.Entry<String, String>> entries = hashMap.entrySet(); for (Map.Entry<String, String> m:entries){ System.out.println(m.getKey()+":"+m.getValue()); }
以上是关于33.Map的主要内容,如果未能解决你的问题,请参考以下文章