-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
  • 81,685
  • 14
  • 140
  • 306
Beta Nyan
  • 27
  • 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
  • 10,270
  • 37
  • 107
  • 197
-1

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

per answer at Create ArrayList from array

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