-1
在我有這樣的代碼Stream.filter()離開零點陣列
int[] array = {1, -1, 2, 3, -4};
Integer[] out = Arrays
.stream(array)
.filter(elem -> elem >= 0) // remove negatives
.boxed()
.collect(Collectors.toList())
.toArray(new Integer[array.length]);
但是濾波操作離開陣列null
S IN的負性元件。爲什麼它不刪除它們?
好像你已經混'int'用'Integer'大多 - > http://stackoverflow.com/questions/42685825/arraystoreexception-thrown-when-converting-hashset-to-array – nullpointer