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);
                }
            }
        }
    
    }
    终身学习者
  • 相关阅读:
    《Python自动化运维:技术与最佳实践》
    舍本求末的运维自动化技术热潮
    Policy Gradients
    Machine Learning Notes Ⅵ
    Machine Learning Notes Ⅴ
    Machine Learning Notes Ⅳ
    Machine Learning Notes Ⅲ
    Machine Learning Notes Ⅱ
    Machine Learning Notes Ⅰ
    在Linux系统中如何把文件拷贝到U盘
  • 原文地址:https://www.cnblogs.com/zuixinxian/p/10341204.html
Copyright © 2011-2022 走看看