I keep having an error like [D@7852e922 when trying to return an array in a method. Please look at my code. (Assignment: updates the Array by replacing all current entries with the value of a and updating it with the value of b.)(only change the method, not the header)
public static void main(String[] args){
double[] num = new double[]{1,2,4,9,-2,1.2};
System.out.println(UpdateEntry(num,2,3));}
public static double[] UpdateEntry (double[] array, int a, int b)
{
double[] newArray = new double[array.length];
for (int j = 0; j < newArray.length; j++){
if (array[j] == a){newArray[j] = b;}
else {newArray[j] = array[j];}
}
return newArray;
}
The output:
[D@7852e922