Normally, I have no issues scanning an array list for certain elements. I am aware of how to structure the while loop etc. However, in this case, I need to use a scanner, but it is giving my issues as seen here:
The following code is intended to use a scanner to input an author and title to check if that exact book (consisting on a precise match of both author AND title) is in the array list.
Most likely I am overlooking something simple, but in any event, I don't need any comments commenting on this being a dumb code etc.
public String checkForBookUsingInfo(){
int index = 0;
Book bookObject = null;
String returnValue = "Book not found";
String title = "";
String author = "";
Boolean isFound = false;
while (index <bookList.size() && isFound == false ){
bookObject = bookList.get(index);
System.out.println("Please enter title of book to search for.");
String anyTitle = keybd.next();
System.out.println("Please enter author of book to search for.");
String anyAuthor = keybd.next();
if ((title.equals(anyTitle)) && (author.equals(anyAuthor))){
returnValue = "Book is in library.";
}
index++;
}
return returnValue;