We get the exception because in file
src/headfirst/designpatterns/command/dinerLambda/Customer.java
on line 12 we make just declaration of Lambda-object as a local variable, and not save the Lambda-object in instance variable "o":
public void createOrder() {
Order o = () -> { cook.makeBurger(); cook.makeFries(); };
}
Therefore we have null-object in file
src/headfirst/designpatterns/command/dinerLambda/Waitress.java
on line 8:
order.orderUp();
We get the exception because in file
src/headfirst/designpatterns/command/dinerLambda/Customer.java
on line 12 we make just declaration of Lambda-object as a local variable, and not save the Lambda-object in instance variable "o
":Therefore we have
null
-object in filesrc/headfirst/designpatterns/command/dinerLambda/Waitress.java
on line 8:order.orderUp();