Java tutorial
//package com.java2s; import java.util.Collection; import org.springframework.beans.BeanWrapper; import org.springframework.beans.BeanWrapperImpl; public class Main { public static int countValue(String propertyName, Object value, Collection<?> collection) { int count = 0; for (Object o : collection) { BeanWrapper bw = new BeanWrapperImpl(o); Object propertyValue = bw.getPropertyValue(propertyName); if (propertyValue.equals(value)) { count++; } } return count; } }