怎樣創(chuàng)建integer類型的數(shù)組?
//將int數(shù)組轉(zhuǎn)換為Integer數(shù)組
int[] nums = {1,2,3,4};
//先將int數(shù)組轉(zhuǎn)換為數(shù)值流
Stream stream = Arrays.stream(nums);
//流中的元素全部裝箱,轉(zhuǎn)換為流
//-->int轉(zhuǎn)為Integer
Stream integerStream = stream.boxed();
//將流轉(zhuǎn)換為數(shù)組
Integer[] integers = integerStream.toArray(Integer[]::new);
System.out.println(Arrays.toString(integers));