分析 java 的 Map<String,Map<String, List<Map<String,Integer>>>>

java 复制代码
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Test02 {
    public static void main(String[] args) {
        //分析方法:由外层向内层逐渐拆解要定义的变量。再由内向外进行变量赋值
        //外层第一层:mapParen
        //表示其类型为 Map 类型。而 mapParen 中的每个元素键的类型为 String ,值的类型为 Map
        Map<String,Map<String, List<Map<String,Integer>>>> mapParen = new HashMap<>();

        //外层第二层即分析 mapParen 变量中元素值的类型。先定义变量 son2
        //其类型为 Map 类型。其中每个元素键的类型为 String ,值的类型为 List 类型
        Map<String,List<Map<String,Integer>>> son2 = new HashMap<>();

        //外层第三层即分析 son2 变量中元素值的类型。先定义变量 son3
        //其类型为 List 类型。其中每个元素的类型为 Map 类型
        List<Map<String,Integer>> son3 = new ArrayList<>();

        //外层第四层
        Map<String,Integer> son4 = new HashMap<>();

        //赋值
        son4.put("小明",25);
        son3.add(son4);
        son2.put("大明",son3);
        mapParen.put("大大明",son2);

        System.out.println(mapParen);
    }
}
相关推荐
uzong2 小时前
程序员从大厂回重庆工作一年
java·后端·面试
kyle~2 小时前
C++---value_type 解决泛型编程中的类型信息获取问题
java·开发语言·c++
NiNi_suanfa5 小时前
【Qt】Qt 批量修改同类对象
开发语言·c++·qt
小糖学代码5 小时前
LLM系列:1.python入门:3.布尔型对象
linux·开发语言·python
Data_agent5 小时前
1688获得1688店铺详情API,python请求示例
开发语言·爬虫·python
妖灵翎幺6 小时前
C++ 中的 :: 操作符详解(一切情况)
开发语言·c++·ide
开心香辣派小星6 小时前
23种设计模式-15解释器模式
java·设计模式·解释器模式
Halo_tjn6 小时前
虚拟机相关实验概述
java·开发语言·windows·计算机
star _chen6 小时前
C++实现完美洗牌算法
开发语言·c++·算法
周杰伦fans6 小时前
pycharm之gitignore设置
开发语言·python·pycharm