The size of the cost
array is 2 but you have declared it of size 1. This will create ArrayIndexOutOfBoundsException
.
Replace the loop with this single statement so that the return type double[]
matches
cost_grd= Total_cost();
1
solved Error passing and getting Array values in Java