I am trying to implement a method within a 'Library' class that allows a member to take out an object of Book that has the Title and Author that the user specifies. It first checks to find a book that matches the title&author, and then checks to ensure the member does not already have that book on loan. Here is the code for my method, please let me know where I am going wrong. The borrowBook and if(memberName.getBooks().contains(...) methods both work independently, however when I use them in this block of code they do not seem to execute.
public void memberBorrowBook1(Member memberName, String title2, String author2)
{
//Test each book object in the library class to see if the parameters match
for(Book a:books) {
if(a.getTitle() == title2 && a.getAuthor() == author2); {
//If title and author match, check to see if the member already has a copy of this book on loan
for(Book b:memberName.getBooks()) {
if(memberName.getBooks().contains(a)) {
System.out.println("Member already has a copy of that book loaned out");
//Otherwise, loan the book out to the member
} else {
memberName.borrowBook(a);
}
}
}
}
}