ToString Java array
•
Java
I have several arrays in a class
I want to implement toString () to print all the values
What should I do?
public String var1[];
public int var2[];
public String var3[][];
public int var4[];
public int var5[][];
public String toString() {
for(String s : var1) {
System.out.println(s.toString());
}
return null;
}
This prints all VAR1 [] contents, but how do I print all? Do I have to circle a circle for everyone?
Solution
You can use arrays Tostring() static helper method is as follows:
String lines[] = getInputArray(); System.out.println(java.util.Arrays.toString(lines));
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
