遍历Map
来源:互联网 发布:淘宝手机搜索不精准 编辑:程序博客网 时间:2024/04/30 12:32
Map提供了一些常用方法,如keySet()、entrySet()等方法。
定义一个Map:
Map<String, Object> map = new HashMap<>(); map.put("Page", 1); map.put("Row", 10); map.put("IsUser", 0); map.put("Type", 1); map.put("UserId", 0);
keySet()方法返回值是Map中key值的集合;
map.keySet().toString()返回如下: [IsUser, UserId, Type, Page, Row]
entrySet()的返回值也是返回一个Set集合,此集合的类型为Map.Entry。
map.entrySet().toString()返回如下:[IsUser=0, UserId=0, Type=1, Page=1, Row=10]
Map.Entry是Map声明的一个内部接口,此接口为泛型,定义为Entry
for (Map.Entry entry : map.entrySet()) { Log.d("xxmap", entry.getKey() + ";" + entry.getValue().toString()); }
返回值为:
D/xxmap:IsUser;0 D/xxmap: UserId;0 D/xxmap: Type;1 D/xxmap: Page;1 D/xxmap: Row;10
0 0
- 遍历MAP
- 遍历Map
- 遍历Map
- map遍历
- Map 遍历
- 遍历map
- 遍历MAP
- Map遍历
- Map 遍历
- MAP遍历
- 遍历Map
- 遍历Map
- 遍历Map
- Map 遍历
- Map遍历。。。。
- Map遍历
- 遍历Map
- map遍历
- windows如何批量修改文件名
- 第十五周项目1(3)——验证希尔排序
- hibernate 一对多,多对一,一对一,多对多 映射
- 51nod 异或凑数
- 令人振奋的好消息!2016年12月8日Google Developers中文网站发布!
- 遍历Map
- 面向对象举例(一) —— 顶点(vertex)、边(edge)与图(graph)
- Linux zip 与 unzip 的用法
- 第十五周 项目一(3)冒泡排序
- Hough变换原理
- 二叉树遍历之morris traversal
- python-vegetables bird 1
- time元素
- spark-submit提交任务的方式