-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
  • 85,076
  • 16
  • 154
  • 332
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,982
  • 40
  • 122
  • 216
-1

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

per answer at Create ArrayList from array

Community
  • 1
  • 1
austin wernli
  • 1,801
  • 12
  • 15