For some reason this method prints out an extra integer at the bottom. For example: It is supposed to only print out 4 x4.
20 20 20 20
20 20 20 20
20 20 20 20
20 20 20 20
20
Any idea how to remove the extra character?
public void gridOfChars(int gridSize) {
for (int i = 0; i < 2; i++) {
for (char n = 'A'; n <= 'Z'; n++)
{
gameList.add(n);
}
}
shuffle(gameList);
copyGameList = gameList.subList(0, (gridSize * 2));
temp = new ArrayList<Character>(copyGameList);
temp2 = new ArrayList<Character>(temp);
temp.addAll(temp2);
shuffle(temp);
gameList = temp;
//displays grid of chars for text display
int newLine = 0;
for (int a = 0; a <= (gridSize * gridSize); a++) {
newLine++;
System.out.print(" " + gameList.get(a));
if (newLine == gridSize)
{
System.out.println();
newLine = 0;
}
}
}
Any assistance will be great thanks, Kimjack.