Skip to content

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException #2

Open
@mayankkt9

Description

@mayankkt9

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 3
at ctci.RobotInAGrid.getPath1(RobotInAGrid.java:49)
at ctci.RobotInAGrid.getPath1(RobotInAGrid.java:56)
at ctci.RobotInAGrid.getPath1(RobotInAGrid.java:56)
at ctci.RobotInAGrid.getPath1(RobotInAGrid.java:56)
at ctci.RobotInAGrid.getPath1(RobotInAGrid.java:41)
at ctci.RobotInAGrid.main(RobotInAGrid.java:33)

Program RobotInAGrid.java
Error Line 70

if (!maze[row][col] || col < 0 || row < 0) {
			return false;
}

Must Be

if (col < 0 || row < 0 || !maze[row][col]) {
			return false;
}

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