Java examples for Collection Framework:Array Element
sum of array elements
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { int[] a = new int[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 }; System.out.println(sum(a)); }/*from w w w . j a v a2s. c om*/ /** * sum of array elements * @param a * @return */ public static int sum(int[] a) { int retval = 0; for (int i : a) { retval += i; } return retval; } }