DEV Community

realNameHidden
realNameHidden

Posted on

1 1 1 1 1

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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay