-1

Probably a very stupid question, but how can I put an array into an ArrayList?

Example:

String[] strings = {"ex","okay",};
ArrayList<String> stringslist = new ArrayList<String>();

Now how do I put everything in strings, into stringlist?

Luiggi Mendoza
  • 83,472
  • 15
  • 149
  • 315
Beta Nyan
  • 25
  • 2

2 Answers2

0

You need to use Arrays.asList() function.

String[] strings = {"ex","okay",};

ArrayList newStringslist = new ArrayList<Element>(Arrays.asList(strings))

Tutorials-Point Link

Also - Create ArrayList from array

Community
  • 1
  • 1
Caffeinated
  • 11,134
  • 39
  • 115
  • 205
-1

new ArrayList<Element>(Arrays.asList(array)) -- JAVA

per answer at Create ArrayList from array

Community
  • 1
  • 1
austin wernli
  • 1,803
  • 10
  • 15