+ 1

I am confused with output of this code. Can someone please explain. Thanks

public class Program { public static void main(String[] args) { for (int i = 1; i <= 5; i++) { for (int j = 1; j <= 3; j++) if (j == 1 && (i % 4) == 1) System.out.print("W"); else if (j > 1 && (i + j) % 2 ==1) System.out.print("W"); else System.out.print("."); System.out.println(); } } }

18th Aug 2017, 11:26 PM
Kamal
4 Antworten
+ 1
It is better to code in the code playground and see the result
19th Aug 2017, 12:40 AM
Irwin Lopez
Irwin Lopez - avatar
+ 1
I know the result which is: WW. ..W .W. ..W WW. How did it work?
19th Aug 2017, 4:24 AM
Kamal
0
OK tell me what do you want to make, Give the question ❔ with example I will make it for you.
19th Aug 2017, 8:35 AM
Irwin Lopez
Irwin Lopez - avatar
0
How does the loop work? which loop works first? the inner loop or the outer loop.
19th Aug 2017, 9:30 AM
Kamal