How to display tictactoe board using map and forEach? : <p>I want to display tic tac toe board. Something like that:</p>

<pre><code>XXX
XXX
XXX
</code></pre>

<p>Is it possible to use for each to achieve that?
I tried to do some:</p>

<pre><code>    Map&lt;Integer, Tile&gt; board = generateBoard();

    for (Map.Entry&lt;Integer, Tile&gt; entry: board.entrySet()){
        System.out.print(entry.getValue().getSign());
    }

    board.forEach((k,v) -&gt; {
        int i = 1;
        if(i % 3 == 0){
            System.out.println();
        }
        System.out.print(v.getSign());
        i++;
    });
</code></pre>

<p>But my output is incorrect. Could you give me any output to achieve me this output?</p>
