Strange toCharArray() behavior

前端 未结 4 1080
长情又很酷
长情又很酷 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
    2021-01-20 04:23

    The first line calls the method

    print(char[] s) 
    

    on the PrintStream which prints what you expect. The second one calls the method

    print(String s)
    

    Where is concatenating the string with the toString implementation of the array which is that ugly thing you get ([C@19821f).

提交回复
热议问题