这是我的代码
public static int[] parseInt(char[] myChar)
{
int[] myInt = new int[myChar.length];
for(int x = 0; x < myChar.length; x++)
{
myInt[x] = (int)myChar[x];
}
return myInt;
}
当我System.out.println(object.parseInt(myChar));
的值为{'1','2','3'}
时,我希望它会使用myInt
的相应unicode值打印{'1','2','3'}
。
相反,我得到[I@15db9742
关于我做错的任何想法?
答案 0 :(得分:0)
那是因为你正在打印对象,因此java显示:
[I - the name of the type (in this case it is one dimensional [ array of int)
@ - joins the string together
15db9742the hashcode of the object.
默认情况下内存地址。您可以使用:
System.out.println(Arrays.asList(parseInt(array)));