• 【ArrayList嵌套HashMap】


    package com.yjf.esupplier.common.test;
    
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Set;
    
    /**
     * @author shusheng
     * @description  ArrayList嵌套HashMap
     * @Email shusheng@yiji.com
     * @date 2018/12/18 15:22
     */
    public class ArrayListIncludeHashMapDemo {
    
        public static void main(String[] args) {
            // 创建集合对象
            ArrayList<HashMap<String, String>> array= new ArrayList<HashMap<String, String>>();
    
            // 创建元素
            HashMap<String, String> hm1 = new HashMap<String, String>();
            hm1.put("周瑜", "小乔");
            hm1.put("吕布", "貂蝉");
            // 把元素添加到 array 里面
            array.add(hm1);
    
            // 创建元素
            HashMap<String, String> hm2 = new HashMap<String, String>();
            hm2.put("郭靖", "黄蓉");
            hm2.put("杨过", "小龙女");
            // 把元素添加到 array 里面
            array.add(hm2);
    
            // 创建元素
            HashMap<String, String> hm3 = new HashMap<String, String>();
            hm3.put("令狐冲", "任盈盈");
            hm3.put("林平之", "岳灵珊");
            // 把元素添加到 array 里面
            array.add(hm3);
    
            // 遍历
            for (HashMap<String, String> hm : array) {
                Set<String> set = hm.keySet();
                for (String key : set) {
                    String value = hm.get(key); System.out.println(key + "---" + value);
                }
            }
        }
    
    }
    终身学习者
  • 相关阅读:
    Python—Socket
    python-—计算器
    Python—I-O多路复用
    Python—redis
    《Python数据分析常用手册》一、NumPy和Pandas篇
    python--Selenium-模拟浏览器
    python--selenium简单模拟百度搜索点击器
    关于selenium实现滑块验证
    python 读写、创建 文件的方法(必看)
    Python 爬虫的工具列表大全
  • 原文地址:https://www.cnblogs.com/zuixinxian/p/10341209.html
Copyright © 2020-2023  润新知