如何做一个哈希图数组? [英] How to do an array of hashmaps?

查看:25
本文介绍了如何做一个哈希图数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我试图做的,但它给了我一个警告:

HashMap[] responseArray = new HashMap[games.size()];

<块引用>

类型安全:HashMap[ ] 类型的表达式需要未经检查的转换才能符合 HashMap[ ]

解决方案

什么给了?有用.忽略它:

@SuppressWarnings("unchecked")

不,你不能参数化它.但是,我宁愿使用 List<Map<K, V>> 代替.

List>listOfMaps = new ArrayList<Map<String, String>>();

要了解有关集合和地图的更多信息,请查看本教程.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆