Concept
Utility
-Example of a loop without a body
class Empty3 { public static void main(String args[]) { int i; int sum = 0; // soma os números até 5 for (i = 1; i <= 5; sum += i++); System.out.println("Sum is " + sum); } }
The program output is: Sum is 15
Loop analysis
The sum is performed completely within the for loop expression.
The iteration expression sum += i++ does the addition and increment of i:
sum += i++;
Breaking down the expression
Importance
The above is the detailed content of Bodiless loops in Java. For more information, please follow other related articles on the PHP Chinese website!