数据存储综合练习_map保存表记录

本文介绍了一个使用Java进行集合操作的示例程序,该程序创建了包含员工信息的多个Map对象,并将这些Map对象存储在一个List中。通过这个例子,读者可以了解到如何在Java中管理和操作复杂的集合数据结构。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Test02.java

package junit.matrix.collections;

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) {
        Map map = new HashMap();
        map.put("id", 0301);
        map.put("name", "Matrix");
        map.put("salary", 33000);
        map.put("department", "A");
        map.put("hireDate", "2015-10");

        Map map2 = new HashMap();
        map2.put("id", 0301);
        map2.put("name", "Matrix");
        map2.put("salary", 33000);
        map2.put("department", "B");
        map2.put("hireDate", "2014-12");

        Map map3 = new HashMap();
        map3.put("id", 0301);
        map3.put("name", "Matrix");
        map3.put("salary", 33000);
        map3.put("department", "C");
        map3.put("hireDate", "2013-07");

        List<Map> list = new ArrayList<Map>();
        list.add(map);
        list.add(map2);
        list.add(map3);
    }

    public static void printEmpName(List<Employee> list) {
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i).getName());
        }
    }
}

运行结果:

Matrix
Tom
Ada
Jack
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

MatrixSparse

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值