Guava的双键map使用

博客主要介绍了Guava和双键map,双键map类似Map<String, Map<String, String>>,最后提及了结果,但未详细说明。

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

一、Guava

<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>30.1-jre</version>
</dependency>

二、双键map

类似Map<String, Map<String, String>>:

import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;

/**
 * <p>标题: guava多键测试</p>
 * <p>功能描述: </p>
 *
 * <p>创建时间: 2021/6/3 9:10</p>
 **/
public class TableTest {

    public static void main(String[] args) {
        // 1. 双键测试
        Table<String, String, String> table = HashBasedTable.create();
        table.put("1", "a", "第1组第a个数据");
        table.put("1", "b", "第1组第b个数据");
        table.put("2", "a", "第2组第a个数据");
        table.put("2", "b", "第2组第b个数据");

        System.out.println(table.get("1", "a"));
        System.out.println(table.get("1", "b"));
        System.out.println(table.get("2", "a"));
        System.out.println(table.get("2", "b"));
    }
}

三、结果

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值