I'm having a scope issue with this method I'm writing not sure how to ensure that array built in the wile loop can be returned once the loop is finished. The method is designed to get an even number to create a Reversi game board. The while loop is in place to ensure the board size is correct. Placing the return statement in the loop causes an error. My question is how to do return my array created in the while loop. The return statement at the bottom is throwing an "cannot find symbol" error.
public static int [][] GetGameBoard(){
//initalizing local.
int sizeChoice = 1;
int black = 1;
int white = 2;
//creating scanner object.
Scanner input = new Scanner(System.in);
//while loop to ensure choice is correct.
while((sizeChoice%2) != 1 && sizeChoice < 4){
//asing user for input.
System.out.println("Please enter the size of the board you want!");
System.out.print("The size must be > 4 and an even number: ");
System.out.println("\n");
sizeChoice = input.nextInt();
if (sizeChoice%2 == 0 && sizeChoice >= 4){
System.out.println("You have chosen a " + sizeChoice + "x"
+ sizeChoice + " board.");
//creating board.
int theBoard[][] = new int[sizeChoice][sizeChoice];
//intializing half way points for board center
int halfWay1 = (sizeChoice/2);
int halfWay2 = (sizeChoice/2) + 1;
theBoard[halfWay1][halfWay1] = black;
theBoard[halfWay1][halfWay2] = white;
theBoard[halfWay2][halfWay1] = white;
theBoard[halfWay2][halfWay2] = black;
}
else if(sizeChoice%2 != 0){
System.out.println("Incorrect input you must choose an even,"
+ "number!");
}
else if (sizeChoice < 4){
System.out.println("Incorect size you must choose a size board"
+ " >= 4.");
}//end of if/else's
}//end of while.
return theBoard;
}// end of GetGameBoard