将String Array添加到ArrayList

时间:2016-04-11 22:37:22

标签: java arrays string arraylist

我有2个String阵列

String[] question1 = {"Q1","Q2","Q3","Q4"};
String[] question2 = {"Q5","Q6","Q7","Q8"};

一个ArrayList

ArrayList<String> aList = new ArrayList<String>();

如果我想访问ArrayList的成员,我该如何操作它们。我尝试将两个数组转换为String,但它没有提供解决方案。

1 个答案:

答案 0 :(得分:21)

ArrayList<String> aList = new ArrayList<String>(Arrays.asList(question1));
aList.addAll(Arrays.asList(question2));