我有一个像这样的数组:
int[] array_example = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
Long count_array = Arrays.stream(array_example)
.filter(x -> x>5)
.count();
还有一个二维数组,就像这样:
int[][] matrix_example = {{0, 1, 2, 3, 4}, {5, 6, 7, 8, 9}};
Long count_matrix = 0L;
for(int[] temp: matrix_example){
for(int x_y: temp){
if(x_y > 5)
count_matrix++;
}
}
如何使用Java 8或更高版本获取矩阵中大于x的元素数量?