zoukankan      html  css  js  c++  java
  • 【HashMap 嵌套 HashMap】

    package com.yjf.esupplier.common.test;
    
    import java.util.HashMap;
    import java.util.Set;
    
    /**
     * @author shusheng
     * @description HashMap 嵌套 HashMap
     * @Email shusheng@yiji.com
     * @date 2018/12/18 14:46
     */
    public class HashMapDemo2 {
    
        public static void main(String[] args) {
            HashMap<String, HashMap<String, Integer>> doubleMap = new HashMap<String, HashMap<String, Integer>>();
    
            // 创建基础班集合对象
            HashMap<String, Integer> jcMap = new HashMap<String, Integer>();
            // 添加元素
            jcMap.put("陈玉楼", 20);
            jcMap.put("高跃", 22);
            // 把基础班添加到大集合
            doubleMap.put("jc", jcMap);
    
            // 创建就业班集合对象
            HashMap<String, Integer> jyMap = new HashMap<String, Integer>();
            // 添加元素
            jyMap.put("李杰", 21);
            jyMap.put("曹石磊", 23);
            // 把基础班添加到大集合
            doubleMap.put("jy", jyMap);
    
            //遍历集合
            Set<String> oneMapSet = doubleMap.keySet();
            for (String mapKey : oneMapSet) {
                System.out.println(mapKey);
                HashMap<String, Integer> mapValue = doubleMap.get(mapKey);
                Set<String> twoMapValueSet = mapValue.keySet();
                for (String mapValueKey : twoMapValueSet) {
                    Integer mapValueValue = mapValue.get(mapValueKey);
                    System.out.println("	" + mapValueKey + "---" + mapValueValue);
                }
            }
        }
    
    }
    终身学习者
  • 相关阅读:
    51nod1363-最小公倍数之和
    [模板] 数论题的一些经验
    WC2019游记 && 课件
    (伪)WC2019题解
    [模板] 后缀自动机&&后缀树
    [模板] 二分图博弈 && BZOJ2463:[中山市选2009]谁能赢呢?
    界面修改日志
    [模板] dp套dp && bzoj5336: [TJOI2018]party
    BZOJ1025:[SCOI2009]游戏
    [模板] BSGS/扩展BSGS
  • 原文地址:https://www.cnblogs.com/zuixinxian/p/10341204.html
Copyright © 2011-2022 走看看