- 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 js=0;
- while(num!=0)
- {
- arr[js] = chs[num&15];
- num=num>>>4;
- js++;
- }
- for (int x=js;x>=0 ;x--)
- {
- System.out.print((char)arr[x]);
- }
- }
- }
复制代码
|
|