使用Java8中的lambda表达式过滤
ModelMap model = new ModelMap(); TSmClazz TSmClazz = tSmClazzService.get(id); List<Student> students = TSmClazz.getStudents(); if(flag.equals("0")){ List<Student> boys =students.stream().filter(s->s.getSex().equals("0")).collect(Collectors.toList()); model.put("data", boys); }else if(flag.equals("1")){ List<Student> girls =students.stream().filter(s->s.getSex().equals("1")).collect(Collectors.toList()); model.put("data", girls); }else{ model.put("data", students); }
标签:java,students,List,equals,put,集合,model,data From: https://www.cnblogs.com/Fooo/p/17441879.html