java流和筛选列表中包含的子列表中的数据
我有一本作者集和一本书集。书和作者之间的联系是作者的电子邮件地址
Book类有Set
个作者的电子邮件地址:private Set<String> autoren
对于每本书,我想得到相应的作者,并打印出作者的姓和名
LinkedList<Author> autoren = (LinkedList<Autor>) dataController.getAutoren().stream()
.filter(s -> buch.getAutoren().contains(s.getEmailadresse()));
for (Author author: autoren) {
sysout(auther.getName())
}
我的布尔数据模型看起来像
public class Buch {
private String title;
private String isbnNummer;
private Set<String> autoren;}
如何获得所有书籍的所有作者的列表,并使用lambda表达式按书籍名称进行筛选
# 1 楼答案
你想要什么还不完全清楚,这里有一个可能有用的例子: