gpt4 book ai didi

java - 在 java 中创建一个二维的 HashMaps 数组

转载 作者:行者123 更新时间:2023-11-30 08:46:04 25 4
gpt4 key购买 nike

我想在 java 中创建一个 3 维数组,其中前两个维度是索引 (0-100) 和 (0-4),第三个维度是字典索引(12、18、22、49 等)

我该如何设置?我想:

    HashMap<Integer, Integer>[][] mem;
mem = new HashMap<Integer, Integer>[101][5];

但是我遇到了错误。我的做法是否正确?

谢谢!

最佳答案

为什么不使用类来包装 HashMap?

class Dictionary {
HashMap<Integer, Integer> map = new HashMap<>();
}


Dictionary[][] mem = new Dictionary[101][5];

关于java - 在 java 中创建一个二维的 HashMaps 数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33061027/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com