I would like to develop a character array output that outputs ONLY a single character in each position. While my programming appear to work fine with filling all spaces with a single character or with 2 characters one each at alternating spaces, its not the same with designated position.
For a 3x3 array[][] with x and x o values respectively I get..
x x x|......|x o x
x x x|......|o x o
x x x|......|x o x
BUT my output for character at designated array position(1,1) is:
00 00 00
00 x 00
00 00 00
I really need to have the following:
0 0 0
0 x 0
0 0 0
Here is the code I have creating the trouble and I suspect the double zeros are coming from my for statements.
// Code to use scanner to select character and designated position
//the character is selected and inserted at the position I
//designate with these code segments so no problem there...
.
.
.
// Insert character into array
char square[][];
square = new char[size][size];
for (int row = 0; row < size; row++) { // allocate array of rows
for (int col = 0; col < size; col++) { // allocate array of columns
System.out.print(" " + square[row][col]);
}
System.out.println(" ");
}
Thanks,
Jems