Men men = new Men(); men.setName("UU"); men.setAge("56"); Men men1 = new Men(); men1.setName("KK"); men1.setAge("23"); Men men2 = new Men(); men2.setName("KK"); men2.setAge(""); List<Men> list = new ArrayList<>(); list.add(men); list.add(men1); list.add(men2); //一般写法 int sum =0; for (Men men3 : list) { if (men3.getName().equals("KK")) { sum = sum + Integer.parseInt(men3.getAge().isEmpty()?"0":men3.getAge()); } } //JAVA8新特性 int kk = list .stream() .filter(t -> t.getName().equals("KK")) .mapToInt(t -> Integer.parseInt(t.getAge().isEmpty()?"0":t.getAge())) .sum(); System.out.println(kk);