|
发表于 2020-8-21 23:45:01
|
显示全部楼层
就是10进制转16进制吧?
public class DecToHex {
public static char table[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
public static void main(String[] args)
{
int sourceDec=Integer.parseInt(args[0]);
int length=0;
int[] digits=new int[20];
while(sourceDec>=16)
{
digits[length++]=sourceDec%16;
sourceDec/=16;
}
digits[length]=sourceDec;
for(int i=length;i>=0;i--)
{
System.out.print(table[digits[i]]);
}
}
}
|
|