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

后端 未结 9 1572
灰色年华
灰色年华 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:57

    Just use the following commands to get your abcdef array printed

        String a= new String(Array);
    
        System.out.println(a);
    

    there you have it problem solved !! now regarding why is printing the other stuff i think those guys above put some useful links for that. Ok gotta go !!

提交回复
热议问题