我有一个 List student 和一个带有变量的 Student 类 Int studentId, String name, Boolean fullTime.
我想从我已有的学生列表中过滤并创建一个新列表,其中包含全日制学生的唯一姓名列表(其中 fullTime 为 True)。
最佳答案
我认为最简单的方法
List<String> filteredNames = new ArrayList<>();
for(Student student : listStudents) {
if(student.isFulltime()) {
filteredNames.add(student.getName());
}
}
关于java - 从自定义数组列表创建一个新列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35324770/