Wednesday 15 June 2011

java - When I try to return the index values of an item in a multidimensional array, I do not get numbers. I get a weird set of characters. Why? -



java - When I try to return the index values of an item in a multidimensional array, I do not get numbers. I get a weird set of characters. Why? -

i have code below supposed homecoming index values of item in multidimensional array. however, when run it, gives me instead:

found at: [i@7ea987ac public static string findword(char[][]board, string word) { (int row = 0; row < board.length; row++) { (int col = 0; col < board[row].length; col++) { if (board[row][col] == word.charat(0)) { homecoming "found at: " + new int[] {row,col}; } } } homecoming "not found."; }

what wrong code not giving me right index values?

you're getting default tostring() array, alter this

return "found at: " + new int[] {row,col};

to utilize arrays.tostring(int[]) like

return "found at: " + arrays.tostring(new int[] {row,col});

java multidimensional-array indexing return

No comments:

Post a Comment