I have several arrays in a class
I want to implement toString() to print all values.
How to do this?
public String var1[];
public int var2
First of all, it depends on the size of your arrays. You did not mention any size for each of it. Of course, we can use for each. The second question obviously, how to want to print them all in the screen. that is the matter.
In case, if you go with normal for loop [ex: for(int i=0;i
If your array size is same for all. You can simply use one loop to iterate all of them to print it off.
Hint: don't forget to handle the ArrayOutofBound exception. You would need that :P