How do you print out the contents of a 2d int array
Ive code written in java for a sudoku game and im trying to create a game on the android using the same code
My code in java reads in a text file(sudoku grid)
i see canvas.drawText will 开发者_StackOverflowread in a string, but how do you do it for a 2d int array, so it prints out in a grid?
This is a pseudo-code, no reference has been made to any java classes. This is just to get an idea flowing:
int[][] my2dArray;
for (int i = 0; i < my2dArray.length; i++) {
for (int j = 0; j < my2dArray[i].length; j++) {
//Draw block
canvas.drawRect(x, y, width, height);
canvas.drawText(Integer.toString(my2dArray[i][j]), textX, textY);
}
}
精彩评论