How to do an array of hashmaps?(如何做一个哈希图数组?)
问题描述
这是我试图做的,但它给了我一个警告:
HashMap[] responseArray = new HashMap[games.size()];
<块引用>
类型安全:HashMap[ ] 类型的表达式需要未经检查的转换才能符合 HashMap[ ]
什么给了?有用.忽略它:
@SuppressWarnings("unchecked")
不,你不能参数化它.但是,我宁愿使用 List<Map<K, V>>
代替.
List
要了解有关集合和地图的更多信息,请查看本教程一个>.
This is what I tried to do, but it gives me a warning:
HashMap<String, String>[] responseArray = new HashMap[games.size()];
Type safety: The expression of type HashMap[ ] needs unchecked conversion to conform to HashMap[ ]
What gives? It works. Just ignore it:
@SuppressWarnings("unchecked")
No, you cannot parameterize it. I'd however rather use a List<Map<K, V>>
instead.
List<Map<String, String>> listOfMaps = new ArrayList<Map<String, String>>();
To learn more about collections and maps, have a look at this tutorial.
这篇关于如何做一个哈希图数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何做一个哈希图数组?


基础教程推荐
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01