提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
数组元素之和
//package com.nowjava; /* 来 自* N o w J a v a . c o m */ 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)); } /** * sum of array elements * @param a * @return */ public static int sum(int[] a) { int retval = 0;