Write a program in Java to display the following pattern:
0 1 0 1
1 0 1 0
0 1 0 1
1 0 1 0
Java
Java Nested for Loops
8 Likes
Answer
publicclassKboatPattern{publicstaticvoidmain(String args[]){for(int i =1; i <=4; i++){int t;if(i %2==0)
t =1;else
t =0;for(int j =1; j <=4; j++){System.out.print(t +" ");if(t ==1)
t =0;else
t =1;}System.out.println();}}}