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();}

    每天多努力一点,你将会变得更好。
  • 相关阅读:
    SpringBoot整合Spring Data Elasticsearch
    Elasticsearch(一)基础入门
    二叉排序树
    数据结构之栈
    数据结构之队列
    MySQL主从备份
    Redis主从复制之哨兵模式(sentinel)
    shiro核心
    MySQL常用命令
    Docker常用命令
  • 原文地址:https://www.cnblogs.com/lidar/p/14314190.html
Copyright © 2011-2022 走看看