Java for loop Question 3

Question

What is the output of the following code?

public class Main {
  public static void main(String args[]) {
    int total = 0;

    for (int i = 0; i < 10; i++) {

      total += i;/* w ww  .j  a  v  a 2  s  .c  o  m*/

    }

    System.out.println(total);
  }
}


45

Note




PreviousNext

Related