I'm trying to finish an AP CS FRQ question. I wrote the code, but it doesn't work. Where have I messed up?
Write a static method rowSums that calculates the sums of each of the rows in a given twodimensional array and returns these sums in a one-dimensional array. The method has one parameter, a twodimensional array arr2D of int values. The array is in row-major order: arr2D[r][c] is the entry at row r and column c. The method returns a one-dimensional array with one entry for each row of arr2D such that each entry is the sum of the corresponding row in arr2D. As a reminder, each row of a two-dimensional array is a one-dimensional array.
` public static int[] rowSums(int[][] arr2D){
int total2 = 0;
int a[] = new int[arr2D.length];
for(int x=0; x<arr2D.length; x++){
for(int n=0; n<arr2D[x].length;n++){
arr2D[x][n] = total2;
a[x] = a[x] + total2;
}
}
return a;
}`