Why does the toString method in java not seem to work for an array

后端 未结 9 1504
灰色年华
灰色年华 2020-11-22 12:25

I want to convert a character array to a string object using the toString() method in java. Here is a snippet of the test code I used:

import java.util.Array         


        
9条回答
  •  失恋的感觉
    2020-11-22 12:54

    The default implementation of the toString method of the char [] class returns a String representation of the base address of the array, which is what is being printed here. We cannot change it, since the class of char [] is not extendable.

提交回复
热议问题