这里有我的两个列表,我想将books列表的值添加到book2列表中以更正输出。
在这里我们需要将一个列表追加或添加到另一个列表中。
如果你知道答案,请在这里分享。
List<Book>books=null;
List<Book> books2=null;
String searchParam=null;
searchParam=txtSearch.getText();
if(category.isSelected()){
List<Category> categorys =null;
categorys=ServiceFactory.getCategoryServiceImpl().findAllByName(searchParam);
for(Category i:categorys){
books=ServiceFactory.getBookServiceImpl().findAllBookByCategoryId(i.getId());
System.out.println(i.getName()+books+"hi..");
在这里我们需要将一个列表追加或添加到另一个列表中。
if(books!=null){
books2=books.add(books2);
}
}
}
for(Book book:books){
txtSearchResult.append(book.getName()+"\n");
}
错误提示
The method add(Book) in the type List<Book> is not applicable for the arguments (List<Book>)
如果你知道答案,请在这里分享。