java - How to pass a function that calls a two dimensional array as a parameter? -
char board[][]=printboard(board); printboard(board); public char[][] printboard (char [][] test){ char[][] game = { {'_','1','2','3'}, {'1','_', '_', '_'}, {'2','_', '_', '_'}, {'3','_', '_', '_'} }; return game; }
hi, wondering how call printboard function? nothing in printboard highlighted in red think problem not calling correctly. help.i'm trying put board in it's own function , call using 2d array variable board[][]. i'm trying make tic tac toe game. when run doesn't print board.
you never call print method, allocate array. below example of how it:
char board[][] = { {'_','1','2','3'}, {'1','_', '_', '_'}, {'2','_', '_', '_'}, {'3','_', '_', '_'} }; (int = 0; < board.length; i++) { (int j = 0; j < board[0].length; j++) { system.out.print(board[i][j] + "\t"); } system.out.println(); }
Comments
Post a Comment