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 )
{
int temp = num&15;
arr[--pos]=chs[temp];
num = num >>> 4;
}
上面那个临时定义的容器为什么长度最大是8?
|
|