// (from the Carter book)
// Example 1. The fragment shown below demonstrates
// the use of commas to build complex expressions
// from simpler 'for' loop statements. HINT: The
// for loop variables, i and j, do NOT have to be
// declared BEFORE the for loop statement.
public class VariationsOnForLoops
{
public static void main (String[] args)
{
for (int i = 0, j = 5 ; i < j && j > 0 ; i++, j--)
{
System.out.println ("i = " + i + " j = " + j);
}
} // main method
} // VariationsOnForLoops class
No comments:
Post a Comment