(三)计算数组中某个值出现的次数

public static long countOccurrences(int[] numbers, int value) {
    return Arrays.stream(numbers)
            .filter(number -> number == value)
            .count();
}

 

posted @ 2018-02-03 01:20  R4mble  阅读(299)  评论(0编辑  收藏  举报