class nm
{
public static void main(String[] args)
{
int num1=60,i=0,j;
int n1,temp1;
char s[]=new char[12];
while(num1!=0)
{
n1=num1&15;
temp1=n1>9?(n1-10+'A'):(n1-0+'0');
s[i]=(char)temp1;
i++;
num1=num1>>>4;
}
for(j=i-1;j>=0;j--)
{
System.out.print(s[i]);
}
}
}
//求出二进制数的十六进制表现形式 num1是二进制数,
帮我看看吧,不知道错哪里了
------解决方案--------------------------------------------------------
char[] hex = new char[]{0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F};
System.out.print(hex[(x >> 24) & 0xFF]);
System.out.print(hex[(x >> 16) & 0xFF]);
System.out.print(hex[(x >> 8) & 0xFF]);
System.out.print(hex[(x >> 0) & 0xFF]);