I'm trying to write a method that takes a two-dimensional array of integers (t) and returns a one-dimensional array (sums) that holds the sum of all the elements for a particular row WITHOUT using arithmetic operators and using a for-each loop.
public static int sumArr(int[] m) { // Returns the sum of a row of a 1-D arr
int sum = 0;
for (int number : m) {
sum = sum + number;
}
return sum;
}
This is a separate method that returns the sum of a row within a 1-D array. As you can see, I use a for-each, however; I need to implicate this method in order to do the above task.
the sum of all the elements for a particular row WITHOUT using arithmetic operators- how would you calculate the sum without addition operator?