38

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
  • 8
    aList.addAll(Arrays.asList(question1)); aList.addAll(Arrays.asList(question2)); Commented Apr 11, 2016 at 22:40

1 Answer 1

69
ArrayList<String> aList = new ArrayList<String>(Arrays.asList(question1));
aList.addAll(Arrays.asList(question2));
Sign up to request clarification or add additional context in comments.

9 Comments

is it posible to add more arrays in list in the same line of the code, something like aList.addAll(Arrays.asList(question1,question2,question3...));
and how i can now to access to some of elements of array
@GlacialMan "is it posible to add more arrays in list in the same line of the code" not really; "and how i can now to access to some of elements of array" - aList.get(0);, perhaps you should take a closer look at Collections Trail
@GlacialMan or maybe take a look at ArrayList API
this will get me Array, but i want to access to element of an array, for example i want to work something with q4 element of Array question1.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.