为什么这个程序执行以后前面就打印空格?0到哪里去了呢?
结果是 , , , ,0,0,3,C,
- class ArrayTest
- {
- public static void main(String[] args)
- {
- toHex(60);
- }
- public static void toHex(int num)
- {
- char[] chs = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
-
- char[] arr = new char[8];
- for (int x=0;x<8 ;x++ )
- {
- int temp = num & 15;
- arr[x] = chs[temp];
- num = num >>> 4;
- System.out.print(arr[7-x]+",");
- }
-
- }
- }
复制代码 |
|