I am trying to print each element in a String array but I seem to only be able to print a specific index.
public String toString() {
return fruits.fruitColor + fruits.fruitName;
}
public String toString() {
return fruits[i].fruitColor + fruits[i].fruitName;
i++; // I don't understand why the int i cannot be incremented to print out the next set of information?
}
I don't know if I like the Arrays.toString(array) method because I don't necessarily want the [] format, but rather specific information from each element in chronological order. I attempted for loops as well in the toString() method, which also failed. Any suggestions are appreciated.