[java] How do you find the sum of all the numbers in an array in Java?

public class AddDemo {

    public static void main(String[] args) {

        ArrayList <Integer>A = new ArrayList<Integer>();

        Scanner S = new Scanner(System.in);

        System.out.println("Enter the Numbers: ");

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

            A.add(S.nextInt());
        }

        System.out.println("You have entered: "+A);

        int Sum = 0;

        for(int i=0; i<A.size(); i++){

            Sum = Sum + A.get(i);

        }

        System.out.println("The Sum of Entered List is: "+Sum);

    }

}

Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to arrays

PHP array value passes to next row Use NSInteger as array index How do I show a message in the foreach loop? Objects are not valid as a React child. If you meant to render a collection of children, use an array instead Iterating over arrays in Python 3 Best way to "push" into C# array Sort Array of object by object field in Angular 6 Checking for duplicate strings in JavaScript array what does numpy ndarray shape do? How to round a numpy array?

Examples related to sum

Iterating over arrays in Python 3 Get total of Pandas column Pandas: sum DataFrame rows for given columns How to find sum of several integers input by user using do/while, While statement or For statement SQL Sum Multiple rows into one Python Pandas counting and summing specific conditions SELECT query with CASE condition and SUM() Using SUMIFS with multiple AND OR conditions How to SUM parts of a column which have same text value in different column in the same row how to count the total number of lines in a text file using python