The do...while of the Java Loop statement
The Do...while loop is somewhat similar to the while loop syntax, but the execution process is quite different.
Syntax: 650) this.width=650; "src=" http://img.mukewang.com/536a018100011a0401720070.jpg "/>
Execution process:
<1>, perform the cycle operation first, and then determine if the loop condition is true
<2>, if the conditions are established, continue to implement < 1 >, < 2, until the cycle conditions are not established
Features: first execution, after judgment
Thus, the Do...while statement guarantees that the loop is executed at least once !
For example, still output 1000 times "I adore class net", using Do...while Implementation code: 650) this.width=650; "Src=" http://img.mukewang.com/ 536a01150001976604830150.jpg "/>
Code:
public class HelloWorld {
public static void Main (string[] args) {
int sum = 0; Save 1-50 even-numbered and
int num = 2; Represents an even number between 1-50
do {
Implementing Cumulative summation
Sum=sum+num;
num = num + 2; The value is added 2 for each execution once to determine the next cyclic condition
} while (NUM<=50); Repeat loop when value is met between 1-50
System.out.println (the sum of the even numbers within 50 is: "+ sums);
}
}
Operation Result:
The sum of the even numbers within 50 is: 650
This article is from "Ghost" blog, please make sure to keep this source http://caizi.blog.51cto.com/5234706/1547752
Java Basics---Do...while of Java loop Statements (23)