0

I need to know why my java for loop is giving infinite output when i=i++ and gives correct output when i=++i;

          for(int i=0; i<=10; i=i++ )
          {
             System.out.println(i);  // This gives an infinite loop ?????
          }

But the below code works fine. Someone can explain?

   for(int i=0; i<=10; i=++i )
      {
          System.out.println(i);  // This works correctly..
      }

0 Answers0