
public static void main(String[] args) {
Map<String, String> map = new HashMap<String, String>();
mapput("1", "v1");
mapput("2", "v2");
for (String key : mapkeySet()) {
Systemoutprintln("key= " + key + " and value= " + mapget(key));
}
}
取key和value
Map map = new Map();Set set = mapentrySet(); Iterator i = setiterator(); while(ihasNext()){ MapEntry entry1=(MapEntry)inext(); Systemoutprintln(entry1getKey()); }这样最终输出的就是map的key值
Set<Integer> keySet = mapkeySet();
for(Integer key : keySet) {
mapget(key);
}
以上就是关于如何取出Map中key和value的值全部的内容,包括:如何取出Map中key和value的值、java map怎么获取key、java获取map中key等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)