int[] ints = {1, 2, 3}; List<Integer> list = Arrays.stream(ints).boxed().collect(Collectors.toList());
使用流式编程声明数组。
1 2 3 4
int [] myIntArray = IntStream.range(0, 100).toArray(); // From 0 to 99 int [] myIntArray = IntStream.rangeClosed(0, 100).toArray(); // From 0 to 100 int [] myIntArray = IntStream.of(12, 25, 36, 85, 28, 96, 47).toArray(); // The order is preserved. int [] myIntArray = IntStream.of(12, 25, 36, 85, 28, 96, 47).sorted().toArray(); // Sort