分析 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);
    }
}
相关推荐
Ekehlaft3 分钟前
这款国产 AI,让 Python 小白也能玩转编程
开发语言·人工智能·python·ai·aipy
rit84324995 分钟前
MATLAB中Teager能量算子提取与解调信号的实现
开发语言·matlab
开源技术8 分钟前
Python GeoPandas基础知识:地图、投影和空间连接
开发语言·ide·python
vx1_Biye_Design10 分钟前
基于Spring Boot+Vue的学生管理系统设计与实现-计算机毕业设计源码46223
java·vue.js·spring boot·spring·eclipse·tomcat·maven
vx_Biye_Design11 分钟前
基于Spring Boot+vue的湖北旅游景点门票预约平台的设计--毕设附源码29593
java·vue.js·spring boot·spring cloud·servlet·eclipse·课程设计
Cult Of11 分钟前
Alicea Wind的个人网站开发日志(2)
开发语言·python·vue
我找到地球的支点啦17 分钟前
通信扩展——扩频技术(超级详细,附带Matlab代码)
开发语言·matlab
hay_lee29 分钟前
Spring AI实现对话聊天-流式输出
java·人工智能·ollama·spring ai
Hx_Ma1635 分钟前
SpringBoot数据源自动管理
java·spring boot·spring
微小冷36 分钟前
Rust异步编程详解
开发语言·rust·async·await·异步编程·tokio