public static int sum(int[] array) { int total = 0; for (int i = 0; i < array.length; i++) { total = total + array[i]; } return total; }
Quote:What do I need to do to this code to get the sum of an array?
int[] arr = {1,2,3,4,5,6}; System.out.println(sum(arr));
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)