如何做好包含HashMap数组? [英] How to do an array of hashmaps?
本文介绍了如何做好包含HashMap数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我试图这样做,但它给了我一个警告:
的HashMap<字符串,字符串> [] = responseArray新的HashMap [games.size()];
类型安全性:类型的HashMap []选中需要转换的前pression符合HashMap类[]
块引用>解决方案怎么办?有用。只是忽略它:
@燮pressWarnings(未登记)
没有,你不能的参数吧。我宁可不过使用
列表与LT;地图< K,V>方式>
而不是列表与LT;地图<字符串,字符串>> listOfMaps =新的ArrayList<地图<字符串,字符串>>();
要了解更多有关集合和地图,看看本教程。
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.
这篇关于如何做好包含HashMap数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文