Как вывести новый масив из елементов в блоке if? Нужно вывести масив из отобраных объектов.
public class BookModel {
private Book[] books;
public BookModel() {
books = DataSourceBooks.getArray();
}
public Book[] getBooks() {
return books;
}
public Book[] getSpecificBook(String s) {
Book[] newBooks;
for (Book book : books) {
if (s.equalsIgnoreCase(book.getAuthor()) ||
s.equalsIgnoreCase(book.getPublisher())) {
}
}
return newBooks;
}
public Book[] getSpecificBook(int year) {
for (Book book : books) {
if (book.getYear() >= year) {
}
}
return
}
public Book[] sortShape() {
Book[] newBook = Arrays.copyOf(books, books.length);
Arrays.sort(newBook, new SortByPublisher());
return newBook;
}
}