Nested For and While Loops in Java (Grids)