So my solution was this: int m = 10; for(int i = 0; i <= m; i++) { for(int j = 0; j < i; j++) { System.out.print(8); } System.out.println(); } which prints exactly like the requested output, but won't work so I copied this solution: for(int i = 0; i < 10; i++) { for(int j = 0; j <= i; j++) { System.out.print(8); } System.out.print("\n"); } which does exactly the same thing and prints the same output, but this one works! I really want to know why? Because I used the same things, 2 for loops. Thanks.