For the life of me I can't figure out why my code is simply printing out in a straight line, rather than 5x5. I know it's a simple solution but I've been coding different programs for days and I can't figure this out at all right now, any help is appreciated!
import java.util.Random; public class RandomWordGame {
private static char[][] letterBoard = new char[5][5];
private static Random r = new Random();
private static char[][] createBoard()
{
for (int i=0; i<letterBoard.length; i++)
{
for (int j=0; j<letterBoard[i].length; j++)
{
letterBoard[i][j] = (char) (r.nextInt(26) + 'a');
System.out.print(letterBoard[i][j]);
}
}
return letterBoard;
}
public static void main(String[] args)
{
letterBoard = createBoard();
}
}
Aucun commentaire:
Enregistrer un commentaire