如何做一组哈希图? [英] How to do an array of hashmaps?
本文介绍了如何做一组哈希图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这就是我试图做的,但它给了我一个警告:
HashMap[] responseArray = new HashMap[games.size()];
<块引用>
类型安全:HashMap[] 类型的表达式需要未经检查的转换以符合 HashMap[]
解决方案
是什么?有用.直接忽略它:
@SuppressWarnings("unchecked")
不,您不能对其进行参数化.然而,我宁愿使用 List
代替.
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.
这篇关于如何做一组哈希图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文