java for each loop summation

www.l‮‬autturi.com
java for each loop summation
/**
 * @author lautturi.com
 * Java example: for each loop summation in java
 */

import java.util.*;

public class Lautturi {

	public static void main(String[] args) {

		int [] num = { 10, 20, 30, 40, 50 };
       
        int sum = 0;

        for (int numbers : num) {
            sum = sum + numbers;

        }
        System.out.println("The total sum is " + sum);

	}
}

output:

The total sum is 150
Created Time:2017-09-06 08:59:46  Author:lautturi