Create columns with arrays, wrong output
So, I've been trying to make some simple columns in Java (yes, I'm very familiar with this) and I just can't get it to "stand" correctly ...
My code is as follows:
int[][] grid = {
{3, 5, 2434},
{2, 4},
{1, 2, 3, 4}
};
in conjunction with:
for(int row=0; row<grid.length; row++){
for (int col=0; col < grid[row].length; col++) {
System.out.println(grid[row][col] + "\t");
}
System.out.println();
}
Which gives me this result:
3
5
2434
2
4
1
2
3
4
This leads me to my confusion. Shoudn't "\ t" just move them like "tab" instead of giving them a newline?
I appreciate the answers.
source to share
The next line is method related println()
and not because of \t
use print()
instead
Your method behaves like it calls print(yourParameters)
and then println () which says
Ends the current line by writing a line separator string . the line separator string is defined by the system property line.separator and is not necessarily a single newline character ('\ n').
source to share