When I was writing the code, I got a question that how to customize the space between letters?
Here is my code:
The code: System.out.print(‘\t’); makes the space between letters is one tab.
The output of the follow code is like:
1 ### A ### B ### C ### D
2 ### A ### B ### C ### D
3 ### A ### B ### C ### D
4 ### A ### B ### C ### D
5 ### A ### B ### C ### D
6 ### A ### B ### C ### D
7 ### A ### B ### C ### D
public static void main(String[] args)
{
char[][] seat = new char[7][5];
for (int row=0; row<7; row++){
seat[row][0] = (char)('1' + row);
}
for (int row=0; row<7; row++){
for (int col=1; col<5; col++){
seat[row][col] = (char)('A'+ col-1);
}
}
for (int row=0; row<7; row++){
for (int col=0; col<5; col++){
System.out.print(seat[row][col]);
System.out.print('\t');
}
System.out.println("");
}
Try
output
see java.util.Formatter API to know more about formatting options