You're testing this.naam
, which is the instance data member of the class. If this is in a constructor as you've said, then unless you have an initializer on it, it's probably null
.
You probably meant to be testing naam
, the argument to the constructor:
if (naam == null || naam.equals("")) {
// ^---------------^------------------ no `this.` here
throw new IllegalArgumentException("Fill in name");
} else {
this.naam = naam;
}
And similarly for geboortedatum
and boeken
.