import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class Demo {
public static void main(String[] args) {
Map<String, String> map=new HashMap<String,String>();
map.put("key1", "L");
map.put("key2", "i");
map.put("key3", "k");
map.put("key4", "e");
map.put("key5", "f");
map.put("key6", "r");
//获取 键值
Set<String> s= map.keySet();
Iterator<String> iter= s.iterator();
while(iter.hasNext()) {
System.out.println(iter.next());
}
//获取值
Collection<String> c= map.values();
Iterator<String> i=c.iterator();
while(i.hasNext()) {
System.out.println(i.next());
}
}
}
最后修改:2019 年 12 月 06 日
© 允许规范转载