为什么一种原始类型需要强制转换而另一种不需要?
/* This method uses stream operations to count how many numbers in a given array
* of integers are negative
*/
public static void countNegatives(int[] nums) {
long howMany = stream(nums) // or: int howMany = (int) stream(nums)
.filter(n -> n < 0)
.count();
System.out.print(howMany);
}
慕神8447489
心有法竹
相关分类