when I was writing my program I came across a problem with arrays and can't find any explanations on how to fix it.
The problem i ran into is how i should go about using an array from the main a method and passing it to a method, but only getting one value as a return rather than the whole array again.
note: the way i have my program set up the array is filled with random numbers every time it is ran.
im not too sure if you can do this or not, but
The way i am currently calling a method is by doing as follows:
"declared variable (not array)" = "name of method" ("the actual array name")
totalSum = sumTotal (randomArray) // example
The method I'm trying to call:
public static int[] sumTotal (int[] totals) {
int total = 0;
for (int i = 0; i < totals.lenght; i++) {
total += totals[i];
}
return total;
}
it keeps giving me a "cannot find symbol
symbol : method sumTotals(int[])
location: class oneDimensionArraysNew"
error when i try to compile,
im not too sure how i would go about fixing this, I appreciate any and all help!!