I struggled to find a solution or at least to point me in the right direction...
Here is my ArrayList: books = new ArrayList();
I have to search objects of Book that contain a title(String). Here is what I have..
The problem being is that I only want to print the second statement if it is not found. But it seems to be printing it as it searches each object in the list?
public void searchBookInCollection(String title)
{
for (Book book : books)
{
if(book.getTitle().equalsIgnoreCase(title))
{
book.displayBookInformation();
}
else
{
System.out.println("Nope we don't have it");
}
}
}