其实视频里老师都讲 了 留意下就行了
代码:
class ZhuanHuan
{
public static void main(String[] args)
{
System.out.println(decimal2Hex(60));
}
public static String decimal2Hex(int decimal) {
char[] ch={'0','1','2','3',
'4','5','6','7',
'8','9','A','B',
'C','D','E','F'};
StringBuffer sb = new StringBuffer();
while(decimal!= 0) {
int temp=decimal&0xf;
sb.insert(0, ch[temp]);
decimal=decimal>>>4;
}
return sb.toString();
}
}
|