[Solved] Error passing and getting Array values in Java

[ad_1]

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

[ad_2]

solved Error passing and getting Array values in Java