Java for loop Question 2

Question

What is the output of the following code?

public class Main {
  public static void main(String args[]) {

    for (int i = 0, j = 10; i < j; i++, j--) {
      System.out.println(i + " " + j);
    }
  }
}


0 10
1 9
2 8
3 7
4 6

Note

You can use two control variable in for loop.




PreviousNext

Related