import java.util.List; import java.util.Map; import java.util.stream.Collectors; public class Main { public static void main(String[] args) { List<ExcelInput> inputs = getExcelInputs(); // 使用lambda表达式和Java Stream API统计getExcelA属性相同的个数 Map<String, Long> countByExcelA = inputs.stream() .collect(Collectors.groupingBy(ExcelInput::getExcelA, Collectors.counting())); // 输出统计结果 countByExcelA.forEach((excelA, count) -> System.out.println(excelA + ": " + count)); } private static List<ExcelInput> getExcelInputs() { // 返回ExcelInput对象的集合 } }