How do I convert int[]
into List
in Java?
Of course, I\'m interested in any other answer than doing it in a loop, item by it
/* Integer[] to List */
Integer[] intArr = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
List arrList = new ArrayList<>();
arrList.addAll(Arrays.asList(intArr));
System.out.println(arrList);
/* Integer[] to Collection */
Integer[] intArr = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
Collection c = Arrays.asList(intArr);