为什么结果多个0、、、
class arr
{
public static void main(String[] args)
{
toHex_1(60);
}
public static void toHex_1(int num)
{
//进制转换10--16
StringBuffer sb = new StringBuffer();
int temp=1;
while(temp!=0)
{
//System.out.println(num&15);
temp = num&15;
if(temp>9)
sb.append((char)(temp-10+'a'));
else
sb.append(temp);
num = num>>>4;
}
System.out.println(sb.reverse());
}
}
|