Strange toCharArray() behavior

前端 未结 4 1079
长情又很酷
长情又很酷 2021-01-20 03:29

I was experimenting with toCharArray() and found some strange behavior.

Suppose private static final char[] HEX_CHARS = \"0123456789abcdef\".toCha

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-20 04:09

    It is because the parameter to println is different in the two calls.

    The first parameter is called with char[] and the second is called with a string, where HEX_CHARS is converted with a call to .toString().

    The println() have an overriden method that accepts a charArray.

提交回复
热议问题