I'm trying to write a maze passage, but when I run it, the pass code falls into a NullPointerException. The labyrinth itself in the console is displayed without problems. Error refers to this section of code:

public boolean nearExit() { Integer[] temp = new Integer[2]; temp = path.peek(); if (temp[1] == searchRoute[0].length - 2) { if (searchRoute[temp[0] + 1][temp[1]] == 'X') { return true; } } return false; } 

All code here: https://github.com/kozloff13/MazeNavigator

It is important that if it is impossible to build a route, null will be returned to the console.

  • And what does debugging show? - MBo
  • @MBo Launched in debugger, everything went step by step. When the loop goes through the entire array, an error appears - Yegor Kozlov
  • And at the same time, path.peek is successfully executed and temp is filled with something correct? - MBo
  • @MBo see when debugging that temp is filled with zero. But when replacing it with another value, the same error appears in the same place - Yegor Kozlov

0