潜行狙击粤语电视剧,幸田朋弘,朋友圈卖境外熊掌
本文为大家分享了使用entryset方法获取map集合中元素的具体代码,供大家参考,具体内容如下
/*--------------------------------- 使用entryset方法取出map集合中的元素: ....该方法是将map集合中key与value的关系存入到了set集合中,这个关系的数据类型是map.entry ....entryset方法返回值类型的具体写法为:set< map.entry<keytype , valuetype> > ----------------------------------*/ package pack04; import java.util.*; public class mapdemo { public static void main(string[] args) { map<integer, string> ma = new hashmap<integer, string>(); //给集合中存入元素 ma.put(1, "abc01"); //这里将基本数据类型自动装箱 ma.put(2, "abc02"); ma.put(3, "abc03"); ma.put(4, "abc04"); //将map集合当中的映射关系取出,存入到set集合当中 set< map.entry<integer, string> > entryset = ma.entryset(); //取迭代器 iterator< map.entry<integer, string> > it = entryset.iterator(); //获取map集合中的元素 while( it.hasnext() ) { map.entry<integer, string> en = it.next(); integer makey = en.getkey(); string mavalue = en.getvalue(); system.out.println( makey + " : " + mavalue ); } } }
注:希望与各位读者相互交流,共同学习进步。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
浅析我对 String、StringBuilder、StringBuffer 的理解
使用IDEA搭建SSM框架的详细教程(spring + springMVC +MyBatis)
Springboot整合freemarker 404问题解决方案
引入mybatis-plus报 Invalid bound statement错误问题的解决方法
网友评论