Code

import java.util.LinkedList;
import java.util.Queue;


public class BFS2 {
    String maze =
        "▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇" +
        "▇ ▇       ▇       ▇ ▇" +
        "▇ ▇ ▇▇▇▇▇ ▇▇▇ ▇▇▇ ▇ ▇" +
        "▇   ▇   ▇ ▇   ▇ ▇   ▇" +
        "▇▇▇▇▇▇▇ ▇ ▇ ▇▇▇ ▇▇▇ ▇" +
        "▇       ▇ ▇   ▇     ▇" +
        "▇ ▇▇▇▇▇▇▇ ▇ ▇ ▇▇▇ ▇▇▇" +
        "▇         ▇ ▇   ▇   ▇" +
        "▇ ▇▇▇▇▇▇▇▇▇▇▇▇▇ ▇▇▇ ▇" +
        "▇ ▇       ▇     ▇ ▇ ▇" +
        "▇ ▇▇▇ ▇▇▇ ▇ ▇▇▇▇▇ ▇ ▇" +
        "▇   ▇   ▇   ▇   ▇ ▇ ▇" +
        "▇▇▇ ▇▇▇ ▇▇▇▇▇ ▇ ▇ ▇ ▇" +
        "▇ ▇     ▇     ▇ ▇ ▇ ▇" +
        "▇ ▇▇▇▇▇▇▇▇▇▇▇ ▇ ▇ ▇ ▇" +
        "▇     ▇     ▇ ▇   ▇ ▇" +
        "▇ ▇▇▇▇▇ ▇ ▇ ▇ ▇ ▇▇▇ ▇" +
        "▇     ▇ ▇ ▇   ▇ ▇   ▇" +
        "▇ ▇▇▇ ▇ ▇ ▇▇▇▇▇▇▇ ▇▇▇" +
        "▇   ▇   ▇           ▇" +
        "▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇";

    private final int end_x = 19;
    private final int end_y = 19;
    private final int[][] visited = new int[end_x + 2][end_y + 2];
    private final int[][] mazeArr = new int[end_x + 2][end_y + 2];
    private final int[] dir_x = {0, 1, -1, 0};
    private final int[] dir_y = {1, 0, 0, -1};
    private boolean find = false;
    private char wallSymbol = '▇';
    private String resPath = "";

    public BFS2() {
        this.readToArr();
    }

    private void printMaze() {
        for (int i = 0; i < end_x + 2; i++) {
            for (int j = 0; j < end_y + 2; j++) {
                if (mazeArr[i][j] == 0) System.out.print("  ");
                else if (mazeArr[i][j] == 1) System.out.print("▇ ");
                else System.out.print("* ");
            }
            System.out.println();
        }
    }

    private void readToArr() {
        int mazeIter = 0;
        for (int i = 0; i < end_x + 2; i++) {
            for (int j = 0; j < end_y + 2; j++) {
                mazeArr[i][j] = maze.charAt(mazeIter) == wallSymbol ? 1 : 0;
                mazeIter++;
            }
        }
    }


    public static void main(String[] args) {
        BFS2 mazeSolver = new BFS2();
        int start_x = 1;
        int start_y = 1;
        System.out.println(mazeSolver.search(start_x, start_y));
    }
}