class Demo8
{
public static void main(String[] args)
{
toHex(60);
}
public static void toHex(int num)
{
char[] chs = new char[]{'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
char[] arr = new char[8];
int pos = 0;
while(num!=0)
{
int temp = num & 15;
arr[pos++] = chs[temp];
num = num >>> 4;
}
System.out.println("pos="+pos);
for(int x=0 ;x<arr.length; x++)
{
System.out.print(arr[x]+",");
}
}
}
以上代码在我电脑运行异常,放到同学那儿电脑就没问题,求大神帮助
本人电脑运行结果:pos=2 C,3,a,a,a,a,a,a,
同学电脑运行结果:pos=2 C,3, , , , , , , |
|