DEV Community

realNameHidden
realNameHidden

Posted on

how to convert array to arraylist in java

for explanation watch the video


import java.util.*;
import java.lang.*;
class Demo{
    public static void main(String[] args){
        Integer[] arr = {1,2,3,4,5};
        //List<Integer> al = new ArrayList<>(Arrays.asList(3,4,5,6));
        //al.add(45);
        List<Integer> al = new ArrayList<>(Arrays.asList(arr));
        System.out.println(al);
    }   
}

Enter fullscreen mode Exit fullscreen mode

Top comments (0)