添加字符串数组来ArrayList的 [英] Add String Array to ArrayList
本文介绍了添加字符串数组来ArrayList的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2 字符串
阵列
的String [] =问题1 {Q1,Q2,Q3,第四季度};
的String [] =问题2 {Q5,Q6,Q7,Q8};
和有一个的ArrayList
的ArrayList<串GT; ALIST =新的ArrayList<串GT;();
如何操作他们,如果我想获得的ArrayList
中的一员。我试图转换两个阵列为String,但不要 ŧ给出的解决方案。
解决方案
的ArrayList<串GT; ALIST =新的ArrayList<串GT;(Arrays.asList(问题1));
aList.addAll(Arrays.asList(问题2));
I have 2 String
Arrays
String[] question1 = {"Q1","Q2","Q3","Q4"};
String[] question2 = {"Q5","Q6","Q7","Q8"};
And one ArrayList
ArrayList<String> aList = new ArrayList<String>();
How can I manipulate them if i want to access to a member of ArrayList
. I tried converting both arrays to String but it don't give solution.
解决方案
ArrayList<String> aList = new ArrayList<String>(Arrays.asList(question1));
aList.addAll(Arrays.asList(question2));
这篇关于添加字符串数组来ArrayList的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文