Hi so im writing a program and i want to return part of an array that does doesnt include null or 0 in it. so the array is originally int and i converted it to string and use this
public String toString(){
// TODO: Return the String with the format of [1,2,3,4] as an example. Have stack items seperated by commas, enclosed inside brackets, and no comma at the end!
if(top ==0 || a== null )
return "[ ]";
String [] d = new String [n];
for(int r=0; r<n ; r++) {
//if (r<0 && a[r] != 0)
d[r] = Integer.toString(a[r]);
}
return "[" + String.join("," , d) + "]";
// This can be removed but is here to prevent the Java error while testing!
}
to return the result i wanted but instead of it returning the valued i need it is returing all the values in the array no matter what if statement i am using. so n =256. can someone plz help me my hw is due soon and its the last part thats been bugging me the entire day.