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")?

Jan B.
  • 6,030
  • 5
  • 32
  • 53

1 Answers1

0

Yes there is like:

List<Integer> myList = new ArrayList<>();
myList.addAll(Arrays.asList("string1","string2"));
Shanu Gupta
  • 3,699
  • 2
  • 19
  • 29