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))…


This content originally appeared on DEV Community and was authored by NJ

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);
    }   
}


This content originally appeared on DEV Community and was authored by NJ


Print Share Comment Cite Upload Translate Updates
APA

NJ | Sciencx (2023-04-29T07:51:05+00:00) how to convert array to arraylist in java. Retrieved from https://www.scien.cx/2023/04/29/how-to-convert-array-to-arraylist-in-java/

MLA
" » how to convert array to arraylist in java." NJ | Sciencx - Saturday April 29, 2023, https://www.scien.cx/2023/04/29/how-to-convert-array-to-arraylist-in-java/
HARVARD
NJ | Sciencx Saturday April 29, 2023 » how to convert array to arraylist in java., viewed ,<https://www.scien.cx/2023/04/29/how-to-convert-array-to-arraylist-in-java/>
VANCOUVER
NJ | Sciencx - » how to convert array to arraylist in java. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/04/29/how-to-convert-array-to-arraylist-in-java/
CHICAGO
" » how to convert array to arraylist in java." NJ | Sciencx - Accessed . https://www.scien.cx/2023/04/29/how-to-convert-array-to-arraylist-in-java/
IEEE
" » how to convert array to arraylist in java." NJ | Sciencx [Online]. Available: https://www.scien.cx/2023/04/29/how-to-convert-array-to-arraylist-in-java/. [Accessed: ]
rf:citation
» how to convert array to arraylist in java | NJ | Sciencx | https://www.scien.cx/2023/04/29/how-to-convert-array-to-arraylist-in-java/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.