I was experimenting with toCharArray() and found some strange behavior.
Suppose private static final char[] HEX_CHARS = "0123456789abcdef".toCharArray();
System.out.println(HEX_CHARS);
/* prints 0123456789abcdef */
System.out.println("this is HEX_CHARS "+HEX_CHARS);
/* prints [C@19821f */
Any theoretical reason behind this?
It is because the parameter to
printlnis different in the two calls.The first parameter is called with
char[]and the second is called with a string, whereHEX_CHARSis converted with a call to.toString().The
println()have an overriden method that accepts a charArray.