0

Is there a way to add multiple strings to List<String> in a single command?

I know a way of populating list as list.add("string"), but is there something like list.add("string1","string2")?

1
  • Yes, list.addAll(<another collection of strings>) Commented Jun 10, 2018 at 7:59

1 Answer 1

0

Yes there is like:

List<Integer> myList = new ArrayList<>();
myList.addAll(Arrays.asList("string1","string2"));
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.