Comma Operator : For « Language Basics « Java






Comma Operator

Comma Operator
 
//: c03:CommaOperator.java
// From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
// www.BruceEckel.com. See copyright notice in CopyRight.txt.

public class CommaOperator {
  public static void main(String[] args) {
    for(int i = 1, j = i + 10; i < 5;
        i++, j = i * 2) {
      System.out.println("i= " + i + " j= " + j);
    }
  }
} ///:~
           
         
  








Related examples in the same category

1.For loop: all conditions
2.for Demofor Demo
3.Check out for loopCheck out for loop
4.Java labeled for loop.Java labeled for loop.
5.Demonstrates for loop by listing all the lowercase ASCII letters.Demonstrates for loop by listing all the lowercase ASCII letters.
6.Declare multiple variables in for loop
7.Infinite For loop Example
8.Multiple expressions in for loops
9.Java program to demonstrate looping 1Java program to demonstrate looping 1
10.Java program to demonstrate loopingJava program to demonstrate looping