get int Array Sum - Java java.lang

Java examples for java.lang:int Array

Description

get int Array Sum

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        int[] num = new int[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 };
        System.out.println(getArraySum(num));
    }//from   www .  ja  va2 s.  co  m

    public static int getArraySum(int[] num) {
        int result = 0;
        for (int i = 0; i < num.length; i++) {
            result += num[i];
        }
        return result;
    }
}

Related Tutorials