Nested while loop in java

package ifelse;

public class Task1 {
     public static void main(String[] args) {

      int row = 5;
      int colum = 5;
      int a = 0;
   while (a < row) {
    int b = 0;
    while (b < colum) {
      if ((a + b) % 2 == 0) {
         System.out.print("1 ");
    }
    else 
    {
         System.out.print("0 ");
            }
     b++;

           }
         System.out.println();
            a++;

                 }
             }




    }

   OUTPUT:
        1 0 1 0 1 
        0 1 0 1 0 
        1 0 1 0 1 
        0 1 0 1 0 
        1 0 1 0 1 

Enter fullscreen mode Exit fullscreen mode

原文链接:Nested while loop in java

© 版权声明
THE END
喜欢就支持一下吧
点赞6 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容