将字符串数组添加到数组列表

2022-09-01 11:38:05

我有 2 个数组String

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

和一个ArrayList

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

如果我想访问ArrayList的成员,我怎么能操纵它们。我尝试将两个数组都转换为String,但它没有给出解决方案。


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

答案 2