Java 将字符串数组添加到 ArrayList
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36560522/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 18:25:48 来源:igfitidea点击:
Add String Array to ArrayList
提问by GlacialMan
I have 2 String
Arrays
我有 2 个String
数组
String[] question1 = {"Q1","Q2","Q3","Q4"};
String[] question2 = {"Q5","Q6","Q7","Q8"};
And one ArrayList
还有一个 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.
如果我想访问ArrayList
. 我尝试将两个数组都转换为 String 但它没有给出解决方案。
采纳答案by user3114639
ArrayList<String> aList = new ArrayList<String>(Arrays.asList(question1));
aList.addAll(Arrays.asList(question2));