4
嗨,我想從列表中檢索學生的名字,我使用過濾方法,但它返回boolean
,所以有沒有其他方法可以這樣做?從列表中返回特定元素
public class Main {
public static void main(String[] args) {
Collection<Student> students=new LinkedList<>();
students.add(new Student("Add","Nitkons",01));
students.add(new Student("Nina","Adinson",02));
students.add(new Student("Mick","McDonald",05));
students.add(new Student("Anna","Lavrova",04));
//doesnt work
Stream<Student> x=students.stream().filter(s->{return s.getName()});
}
}