Java – strange tochararray () behavior

I'm trying to use 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 */

What is the theoretical reason behind this?

Solution

This is because the parameters of println are different in the two calls

The first parameter is called with char [] and the second parameter is called with string, where hex_ Chars is called by Tostring()

Println () has an override method that accepts chararray

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
分享
二维码
< <上一篇
下一篇>>