Simple Array Sum

  • + 0 comments

    for java , we are getting input as list type array so our code will be a bit different than the simple array, code will be like this if you find any correction please let me know too.

    public static int simpleArraySum(List<Integer> ar) {
        int sum = 0;
        for(int i=0; i<ar.size();i++)
             {
                sum+=ar.get(i);
             }
            return sum;
        }