Ok, so this sounds simple. but its been playing with my head for a little while now.
I need to create a method which finds the sum of a 2d array of integers.
I need to create the method:
public static int sum(int[][] array)
this is what i done so far:
public static int sum(int[][] array){
int sum1 = 0;
for (int i : array)
sum1 += i;
return sum1;
}
But I'm getting an error 'incompatible types required int[] found int.'.
Anyone that can help me complete this challenge?
Thanks. Edit: an example array would be:
3 -1 4 0
5 9 -2 6
5 3 7 -8
for now they will always be of this format (4x3).