的ArrayList< HashMap中<字符串,字符串>>以字符串[] [英] ArrayList<HashMap<String,String>> to String[]

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

问题描述

  ArrayList< HashMap< String,String>> 

现在我想将上面的每个对象转换为

 字符串[] 

我该怎么办这个?
任何帮助将非常感谢!

解决方案

试试

  ArrayList< HashMap< String,String>> test = new ArrayList< HashMap< String,String>>(); 
HashMap< String,String> n = new HashMap< String,String>();
n.put(a,a);
n.put(b,b);
test.add(n);

HashMap< String,String> m = test.get(0); //它将得到第一个HashMap存储在数组列表中

String strArr [] = new String [m.size()];
int i = 0; (字符串current:hash.values()){
strArr [i] = current;
for(HashMap< String,String> hash:test)
i ++;
}
}


i have data fetched from my webservice in

ArrayList<HashMap<String,String>>

Now i want to convert each object of the above to

String[]

how do i do this? any help would be much appreciated!

解决方案

try

ArrayList<HashMap<String, String>> test = new ArrayList<HashMap<String, String>>();
HashMap<String, String> n = new HashMap<String, String>();
n.put("a", "a");
n.put("b", "b");
test.add(n);

HashMap<String, String> m = test.get(0);//it will get the first HashMap Stored in array list 

String strArr[] = new String[m.size()];
int i = 0;
for (HashMap<String, String> hash : test) {
    for (String current : hash.values()) {
        strArr[i] = current;
        i++;
    }
}

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

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