string to char array, showing silly characters

最后都变了- 提交于 2019-12-02 04:39:29

That's how toString() is implemented for arrays.

The [C denotes that is a char array, 177b4d3 is its hashcode.

You may want to look at

System.out.println(Arrays.toString(queryNo) + " =this is no");

if you want to see your original String again, you need this:

System.out.println((new String(queryNo)) + " =this is no");

Arrays do not override toString(), it is inherited from Object.toString as

public String toString() {
    return getClass().getName() + "@" + Integer.toHexString(hashCode());
}

you are printing the object

queryno, as queryno is a character array of on dimension and java is an object oriented language which holds every thing in the form of classes it gives the class name [C to your array where [ denotes total dimension and C denotes character type of array, Rest is the hashcode of the object.

You are trying to print the array and that is the reason you get gibberish. Try using Arrays.toString(queryNo) and you will see what you expected.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!