Java Code Example: sum up all numbers from an array

In this Java code example, all elements from an array are summed up.

import java.util.Scanner;

public class SumUpNumbers {
    public static void main(String[] args) {
        int numbers[] = { 65, 34, 23, 75, 76, 33, 12, 9, 44 };

        int sum = 0;

        for (int i = 0; i < numbers.length; i++) {
            sum += numbers[i];
        }

        System.out.println("Sum of all elements in the array is: " + sum);
    }
}
Output
Sum of all elements in the array is: 371