【发布时间】:2020-09-03 16:32:50
【问题描述】:
我有一个数组列表,其中所有条目如下所示:
ListOfBooks.add(new Book("Holes", "Louis Sachar", 440419468, "Fiction", 1998, 5, 4));
但我只知道如何过滤掉包含字符串的数组列表。我正在为条目使用构造函数:
public Book(String a, String b, int c, String d, int e, int f, int g) {
this.title = a;
this.author = b;
this.isbn = c;
this.genre = d;
this.year = e;
this.rating = f;
this.copies = g;
}
我的问题是,如何仅根据书名过滤书籍列表?
【问题讨论】:
-
你有没有尝试过?
-
看一下Stream接口中的
filter方法。另外,看看Collectors.groupingBy -
我已经尝试了来自this页面的东西。
标签: java filter constructor