I have an array, in this case double [] v, which will take 4 values (0, 1, 2, 3).
I need to multiply each element of the array by "c" and store the result of each one back in a new array. I have tried it but i always end up getting the error message that double cannot be converted to double []. I can't figure out why and the examples here in SO have not helped.
public class q7_2014 {
public static double [] multiply ( double [] v, double c){
double [] newArray = new double [4];
double multiply = 0;
for (int i = 0; i < v.length; i++){
multiply = v[i]*c;
System.out.println(multiply);
}
return newArray;
}
}
The code works fine and prints what is supposed to go into the array, but I just can't figure out how.
what am I missing? (the print statement was just to check if the code was working as expected in terms of results). Thanks