Object toString can be converted to a string.
Object.toString();
- But char [] No, starting valueOf.
String.valueOf(char[]);
If toString, output is the address
public class Test2 {
public static void main(String[] args) {
char[] chArray= {'1','5','6'};
System.out.println(chArray.toString());
System.out.println(String.valueOf(chArray));
}
}
I looked under the Java source code:
- toString()
Object Each object has its own hash code, there is a method by some method within the hash code into String Integer.
String.valueOf
The char [] configured as String