学习博客:HashMap嵌套HashMap嵌套ArrayList使用

需求:
//计算机学院有两个专业 网络工程和软件工程
//软件工程有两个班
//一班有: xbh 20 lzc 21
//二班有: mfc 21 wlx 20
// 网络工程有两个班
//一班有: hql 20 jxf 21
//二班有: zsp 21 lfl 20
// 要求用HashMap储存1-2级用Arraylist存储底层
什么也不多bb了直接贴代码,困了:

package cn.zsp.map_study_07;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;

//计算机学院有两个专业 网络工程和软件工程
//软件工程有两个班
//一班有: xbh 20  lzc 21
//二班有: mfc 21  wlx 20
// 网络工程有两个班
//一班有: hql 20  jxf 21
//二班有: zsp 21 lfl 20
// 要求用HashMap储存1-2级用Arraylist存储底层
public class ThirdHashMap {
    public static void main(String[] args) {
        HashMap<String,HashMap<String, ArrayList<Student>>> jk=new  HashMap<String,HashMap<String, ArrayList<Student>>>();
        HashMap<String, ArrayList<Student>>  wlgc =new HashMap<String, ArrayList<Student>>();
        HashMap<String, ArrayList<Student>>  rjgc =new HashMap<String, ArrayList<Student>>();
        ArrayList<Student> class01 =new ArrayList<Student>();
        ArrayList<Student> class02 =new ArrayList<Student>();
        ArrayList<Student> class11 =new ArrayList<Student>();
        ArrayList<Student> class12 =new ArrayList<Student>();
        class01.add(new Student("xbh",24));
        class01.add(new Student("lzz",25));
        class02.add(new Student("mfc",24));
        class02.add(new Student("wlx",20));
        class11.add(new Student("hql",20));
        class11.add(new Student("jxf",21));
        class12.add(new Student("zsp",21));
        class12.add(new Student("lfl",20));
        rjgc.put("一班",class01);
        rjgc.put("二班",class02);
        wlgc.put("一班",class11);
        wlgc.put("二班",class12);
        jk.put("网络工程",wlgc);
        jk.put("软件工程",rjgc);
        Set<String> jkset =jk.keySet();
        for (String jkkey :jkset)
        {
            System.out.println(jkkey);
            Set <String>departmentset =jk.get(jkkey).keySet();
            for (String departmentkey :departmentset )
            {
                System.out.println(departmentkey);

                for (Student student : jk.get(jkkey).get(departmentkey)  ){
                    System.out.println(student.getName()+"----年龄是:"+student.getAge());
                }


            }



        }
    }

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值