标签:hashmap ash keyset print main rgs sys pre for
public class Demo12 {
public static void main(String[] args){
HashMap<String, String> map = new HashMap<>();
map.put("杨过","小龙女");
map.put("五阿哥","小燕子");
//遍历
//获取所有的键
Set<String> key = map.keySet();
//遍历键的集合,获取到每一个键
for (String x:key){
//根据键找值
String value = map.get(x);
System.out.println(x+"-----"+value);
}
}
}
标签:hashmap ash keyset print main rgs sys pre for
原文地址:https://www.cnblogs.com/WTBK/p/9426640.html