char[][] board = {
{'#','#','#','-','@','-','#','#','#'},
{'#','#','-','@','@','@','-','#','#'},
{'#','-','@','@','-','@','@','-','#'},
{'-','@','@','@','@','@','@','@','-'}};
System.out.println(String.format("Rows: %o, Columns: %o", board.length, board[0].length));
由于某种原因,Java输出11列。感谢任何帮助。
答案 0 :(得分:9)
使用%d
,而不是%o
。 %o
将以八进制显示结果。八进制11等于十进制9。