zoukankan      html  css  js  c++  java
  • 判断Map集合中是否存在某一个key

    转载地址:https://www.cnblogs.com/yang-xiansen/p/10563284.html

     1 方法一:
     2 Map<String,String> hashmp = ne HashMap();
     3 hashmp.put("aa", "111");
     4 hashmap.containsKey("xxx");
     5 
     6 
     7 方法二:keySet()
     8 HashMap hashmp = ne HashMap();
     9 hashmp.put("aa", "111");
    10 Set set = hashmp.keySet();
    11 Iterator iter = set.iterator();
    12 while (iter.hasNext()) {
    13 String key = (String) iter.next();
    14 // printkey
    15 }
    16 // traverse
    17 for (String key : list.get(pos).keySet() ) {
    18 myKey = key;
    19 }
    20 
    21 
    22 方法三:entrySet()
    23 HashMap map;
    24 Iterator i = map.entrySet().iterator();
    25 while (i.hasNext()) {
    26 Object obj = i.next();
    27 String key = obj.toString();
    28 }
    29 // or
    30 while (i.hasNext()) {
    31 Entry entry = (java.util.Map.Entry)it.next();
    32 entry.getkey();
    33 entry.getValue();
    34 }

    方法一:Map<String,String> hashmp = ne HashMap();hashmp.put("aa", "111");hashmap.containsKey("xxx");

    方法二:keySet()HashMap hashmp = ne HashMap();hashmp.put("aa", "111");Set set = hashmp.keySet();Iterator iter = set.iterator();while (iter.hasNext()) {String key = (String) iter.next();// printkey}// traversefor (String key : list.get(pos).keySet() ) {myKey = key;}

    方法三:entrySet()HashMap map;Iterator i = map.entrySet().iterator();while (i.hasNext()) {Object obj = i.next();String key = obj.toString();}// orwhile (i.hasNext()) {Entry entry = (java.util.Map.Entry)it.next();entry.getkey();entry.getValue();}

    每天多努力一点,你将会变得更好。
  • 相关阅读:
    移动端调试Vconsole
    Vue-返回顶部
    Vue-封装loading
    Vue-水印封装
    Vue-封装scroll触底
    微信小程序-图片上传
    前端面试题(2)
    前端常见面试题
    服务端渲染(SSR)和客户端(CSR)渲染的区别
    什么是模块化?模块化开发的好处
  • 原文地址:https://www.cnblogs.com/lidar/p/14314190.html
Copyright © 2011-2022 走看看