how to convert array to arraylist in java

realNameHidden - Apr 29 '23 - - Dev Community

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
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .