Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command Pattern, Diner with Lambda, Exception java.lang.NullPointerException #40

Open
sashkov opened this issue Sep 29, 2023 · 0 comments

Comments

@sashkov
Copy link

sashkov commented Sep 29, 2023

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();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant