标签:static main string int array str out oop for
public class ArrayDemo { public static void main(String[] args) { int[] a = {1, -9, 34, 67, 0, 12 ,34 ,5, 6, 11}; System.out.println(Sum(a)); } static int Sum(int[] arr) { int sum = 0; for (int i = 0; i < arr.length; ++i) { sum += arr[i]; } //或者用下面for-each loop // for (int n : arr) // { // sum += n; // } return sum; } }
标签:static main string int array str out oop for
原文地址:https://www.cnblogs.com/profesor/p/13125863.html