How to create Arraylist from Array in Java

To create Arraylist from given array use below code

new ArrayList<>(Arrays.asList(array));



import java.util.ArrayList;
import java.util.Arrays;

public class JavaApplication1 {

    public static void main(String[] args) {
        String name[]=new String[]{
            "Name 1",
            "Name 2",
            "Name 3"
        ArrayList<String>arrayList=new ArrayList<>(Arrays.asList(name));
        for(int k=0;k         System.out.println(arrayList.get(k));


Name 1
Name 2
Name 3


Subscribe For Daily Updates

Flutter Questions
Android Questions