Add String Array to ArrayList [duplicate]

喜欢而已 提交于 2020-07-02 07:13:08

问题


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 doesn't give solution.


回答1:


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


来源:https://stackoverflow.com/questions/36560522/add-string-array-to-arraylist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!