How to add an Integer array to a List in Java

1 Answer

0 votes
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
 
public class MyClass {
    public static void main(String args[]) {
        Integer[] array = {2, 3, 6, 5, 30, 0};
          
        List<Integer> list = new ArrayList<>(Arrays.asList(array));
  
        System.out.println(list);
    }
}
 
  
  
  
  
/*
run:
   
[2, 3, 6, 5, 30, 0]
   
*/

 



answered Jul 23, 2023 by avibootz
edited Jul 23, 2023 by avibootz

Related questions

1 answer 89 views
1 answer 85 views
4 answers 170 views
2 answers 109 views
1 answer 80 views
80 views asked Jan 2, 2022 by avibootz
...