Skip to content

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

@sashkov

Description

@sashkov

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions