Posts

Showing posts from March 17, 2019

Error passing and getting Array values in Java

Image
-6 0 How I pass an array to another array? I need to pass an array of double values but I don't know why it doesn't work. This is my code: private double Total_cost(){ double cost=new double[2]; . . . cost[0]=tot_cost; cost[1]=tot_cost2; return cost; } Calling the method: public void estr_grdcmpabs(){ // double cost_grd=new double[2]; . . . cost_grd= Total_cost(); cst = String.valueOf(cost_grd[0]); } I get the error: Exception in thread "main" java.lang.NullPointerException How I convert the array value to a string to show in jframe? Thanks. java arrays methods share | improve this question