今天翻看视频,重新敲下代码,出来的结果纠结了差不多半小时才发现问题了= =赶脚好坑爹,看来光看视频之余代码还是得多敲啊{:3_63:}
- class JinZhi
- {
- 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];
-
- int pos=arr.length;
- while(num!=0)
- {
- arr[--pos] = chs[num&15];
- num=num>>>4;
- }
- for (int x=pos;x<arr.length ;x++)
- {
- System.out.print(arr[x]+',');
- }
- }
- }
复制代码
|
|