Home > Back-end >  Why the second while loop starts from the score=6?
Why the second while loop starts from the score=6?

Time:09-23

The first to do the final number before the end of the while loop should be 7,
Why the second while loop of the first cycle results is 6?



Public class Demo19
{
Public static void main (String [] args)
{
Int score=9;
Do
{
System. The out. Println (score);
Score -;
} while (score> 6);
//a single statement braces can omit
{
System. The out. Println (" end of the loop ");
}
While (score<9)
{
System. The out. Println (score);
Score++;
}
System. The out. Println (" end of the loop ");
}
}

CodePudding user response:

refer to the original poster ClickDance response:
first the do while loop before the end of the last number is 7,
Why the second while loop of the first cycle results is 6?


How is 7, 7 satisfy the conditions for more than 6, so only when the score=6 out of the first cycle,

CodePudding user response:

After the first cycle to cycle, print score, score=6 after 7 out of circulation,

CodePudding user response:

The first while loop out of the loop is score=6

CodePudding user response:

Your side the first loop 7 & gt; So will continue to execute, 7 -- into 6, 6!> 6 so is beginning

CodePudding user response:

Thank you, I see the
  • Related