How do I convert int[] into List in Java?
int[]
List
Of course, I\'m interested in any other answer than doing it in a loop, item by it
In Java 8 with stream:
int[] ints = {1, 2, 3}; List list = new ArrayList(); Collections.addAll(list, Arrays.stream(ints).boxed().toArray(Integer[]::new));
or with Collectors
List list = Arrays.stream(ints).boxed().collect(Collectors.toList());