I want to display tic tac toe board. Something like that:
XXX
XXX
XXX
Is it possible to use for each to achieve that? I tried to do some:
Map<Integer, Tile> board = generateBoard();
for (Map.Entry<Integer, Tile> entry: board.entrySet()){
System.out.print(entry.getValue().getSign());
}
board.forEach((k,v) -> {
int i = 1;
if(i % 3 == 0){
System.out.println();
}
System.out.print(v.getSign());
i++;
});
But my output is incorrect. Could you give me any output to achieve me this output?