HashMap的<字符串,字符串>从ArrayList中&LT取值> [英] Take values from ArrayList<HashMap<String, String>>

查看:87
本文介绍了HashMap的<字符串,字符串>从ArrayList中&LT取值>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于从得到一个价值问题,我的的ArrayList<&HashMap的LT;字符串,字符串>方式>

I have a problem about getting a value from my ArrayList<HashMap<String, String>>.

我的code是:

ArrayList<HashMap<String, String>> myArrayList;

和则:

HashMap<String, String> map = new HashMap<String, String>();
map.put(TAG_ID, id);
map.put(TAG_NAME, name);
myArrayList.add(map);

如果我想要得到的名称,例如,我尝试如下,但我得到一个运行时错误(应用程序崩溃):

If I want to get the name, for example, I tried as follow but I obtain a runtime error (the application crashes):

System.out.println(myArrayList.get(1).get(TAG_NAME));

我该如何解决呢?

How can I solve it?

非常感谢你!

推荐答案

的System.out.println(myArrayList.get(1)获得(TAG_NAME));

的ArrayList 0为主。 GET(0)代替。

这篇关于HashMap的&LT;字符串,字符串&GT;从ArrayList中&LT取值&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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