Here you can find the source of sum(int[] numbers)
public static int sum(int[] numbers)
//package com.java2s; //License from project: Open Source License public class Main { public static int sum(int[] numbers) { int s = 0; for (int number : numbers) s += number;/*from w w w . j a va 2 s. c o m*/ return s; } public static int sum(int[] numbers, int limit) { int s = 0; for (int i = 0; i < numbers.length && i < limit; i++) s += numbers[i]; return s; } public static float sum(float[] numbers) { float s = 0; for (float number : numbers) s += number; return s; } public static float sum(float[] numbers, int limit) { float s = 0; for (int i = 0; i < numbers.length && i < limit; i++) s += numbers[i]; return s; } }