Не могу правильно дать значение null переменной
Создаю 2 класса читатели и книги которые находится в библиотеке, мне надо сделать так чтобы когда книга находится у читателя это же книга была null в библиотеке
package com.company;
public class Book extends Reader{
private String author;
private String dateOfProduct;
private String nBook;
public Book(String author, String dateOfProduct, String nBook){
this.author = author;
this.dateOfProduct = dateOfProduct;
this.nBook = nBook;
}
public String getBook() {
if (infoBook == this.nBook) {
return nBook + " " + author + " " + dateOfProduct;
}
else {
return null;
}
}}
package com.company;
import java.util.ArrayList;
public class Reader{
private int id;
private static int id_gen = 1;
private ArrayList<String> Books = new ArrayList<>();
private String Name;
public String infoBook;
public Reader(){
this.id = id_gen;
this.Books = null;
}
public Reader(String Name){
this.Name = Name;
this.id = id_gen++;
}
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
public ArrayList<String> getBooks() {
return Books;
}
public void setBooks(String str) {
Books.add(str);
this.infoBook = str;
}
public String showAllElement(){
return id + " " + Name + " " + Books;
}
}