Hi David,
The NullPointerException is coming from line 103 in the class PhoneBook, which reads as follows:
if
(person.getName().contains(keyword) || person.getAddress().contains(keyword)) {
The problem here is that when you create a new Person, you set his/her address as null on line 13 of the Person class.
Suppose you have a single person in the phone book with only a phone number and no address.
Now if you call the method filtered(), then it first calls person.getName(), which returns a
String and then calls contains(keyword) on that String. Assuming the String does not
contain the keyword, we then move onwards to the second part of the if clause. In this part we
first call person.getAddress(), which in our case returns null. And then we try to call the method
contains(keyword) of the null object, which is not allowed and causes the NullPointerException.
EDIT: The formatting was funky, added some linebreaks. Sorry.
-Leo