Here you can find the source of countNotNull(Collection
protected static int countNotNull(Collection<String> collection)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { protected static int countNotNull(Collection<String> collection) { int i = 0; for (String item : collection) { if (item != null && !"!".equals(toKey(item))) { i++;//from w w w .ja va 2 s . c o m } } return i; } protected static String toKey(String text) { if (text == null) { return null; } return text.substring(0, Math.min(text.length(), 1)); } }