java - Else can't find the If statement even though there is one -


when try compile code error saying else without if. believe have of braces in right place. other errors in picture have attached believe there because of can't use else without if error.

problem code:

public static boolean gonorth(){         boolean success;         if(maze[currcol]currrow - 1] == clear){             maze[currcol][startrow -1] = path;             currrow--;             success = gonorth();                 if(!success){                 success = gowest();                     if(!success){                     success = goeast();                         if(!success){                             maze[currcol][currrow] = visited;                             currrow++;                             }                         }                     }                     return success;                 } else {                     return false;             }         }      public static boolean gowest(){         boolean success;         if(maze[currcol - 1]currrow] == clear){             maze[currcol - 1][startrow] = path;             currrow--;             success = gowest();                 if(!success){                 success = gosouth();                     if(!success){                     success = gonorth();                         if(!success){                             maze[currcol][currrow] = visited;                             currcol++;                             }                         }                     }                     return success;                 } else {                     return false;             }         }          public static boolean goeast(){         boolean success;         if(maze[currcol + 1]currrow] == clear){             maze[currcol + 1][startrow] = path;             currrow--;             success = goeast();                 if(!success){                 success = gonorth();                     if(!success){                     success = gosouth();                         if(!success){                             maze[currcol][currrow] = visited;                             currcol--;                             }                         }                     }                     return success;                 } else {                     return false;             }         }          public static boolean gosouth(){         boolean success;         if(maze[currcol]currrow + 1] == clear){             maze[currcol][startrow + 1] = path;             currrow--;             success = gosouth();                 if(!success){                 success = goeast();                     if(!success){                     success = gowest();                         if(!success){                             maze[currcol][currrow] = visited;                             currrow--;                             }                         }                     }                     return success;                 } else {                     return false;             }         } 

error:

screen shot

    if(maze[currcol + 1]currrow] == clear){ 

that's not valid; you're missing left bracket around currrow in few places.

also, there's chunk of refactoring around this.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -