Here you can find the source of countOccurence(List
public static int countOccurence(List<Integer> valueList, int value)
//package com.java2s; //License from project: Apache License import java.util.Iterator; import java.util.List; public class Main { public static int countOccurence(List<Integer> valueList, int value) { int count = 0; Iterator<Integer> iterValueList = valueList.iterator(); while (iterValueList.hasNext()) { int vaInList = iterValueList.next(); if (vaInList == value) { count++;/*from w w w . j av a 2 s .c o m*/ } } return count; } }