How to switch data from an array to array list in java?
Answers
Answered by
0
Answer:
the array class of the java.util package provides you a method named as list().this method accepts an array(of objects) and converts them into a list and returns it.
Attachments:
Answered by
0
We can convert an Array into an ArrayList in Java using a class from java.util package called Arrays.
We can import this class and convert our Array to an ArrayList.
For example -
Given, an Array,
String[ ] myArray = {"One", "Two", "Three", "Four", "Five"};
For converting,
ArrayList<String> myArrayList = new ArrayList<>(Arrays.asList(myArray)); or,
var myArrayList = new ArrayList<>(Arrays.asList(myArray));
Similar questions
India Languages,
6 months ago
Science,
6 months ago
Economy,
1 year ago
Physics,
1 year ago
Math,
1 year ago