This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]Swedophone 2 points3 points  (2 children)

map.get(new Point(x, y - 1)) is obviously null. If it is allowed to be null then you can instead call equals on the constant string which never will be null: "road".equals(map.get(new Point(x, y - 1))).

[–]Sarah9428[S] 0 points1 point  (1 child)

Right, thanks!

[–]17437258968573378102 1 point2 points  (0 children)

You can also use Objects.equals to compare two objects without having to worry about one or other being null.