• 2021-04-14
    以下Student类可直接使用。 public class Student { private int number; private String name; private String clazz; private int score; public Student(int number, String name, String clazz, int score) { this.number = number; this.name = name; this.clazz = clazz; this.score = score; } // 省略getter/setter方法 } 在以下类中,按需求编写方法,完成对STUDENTS集合的操作 public class StreamTest { private static final List STUDENTS = create(); private static final String CLAZZ1 = "软件1班"; private static final String CLAZZ2 = "软件2班"; private static List create() { Student s1 = new Student(2018008, "张扬", CLAZZ2, 66); Student s2 = new Student(2018005, "刘飞", CLAZZ1, 92); Student s3 = new Student(2018007, "李明", CLAZZ2, 42); Student s4 = new Student(2018006, "赵勇", CLAZZ2, 56); Student s5 = new Student(2018002, "王磊", CLAZZ1, 81); Student s6 = new Student(2018010, "牛娜", CLAZZ1, 78); List students = new ArrayList<>(); students.add(s1);students.add(s2);students.add(s3); students.add(s4);students.add(s5);students.add(s6); return students; } public static void main(String[] args) { // 调用实现方法测试 } // 实现方法 } 说明: 需求描述中的指定X,均指方法的参数 所有方法均有返回值,尝试直接编程return语句,基于stream操作流直接返回所需结果 如果返回集合,使用List集合类型 尝试使用简写 注意过滤代码格式 方法1,获取成绩小于等于指定分数,的全部学生
  • 举一反三