import java.util.ArrayList; public class intToHex_Alter { public static void main(String[] args) { //十进制转十六进制 int a = 31; //需要转换的十进制值 StringBuilder stringBuilder = new StringBuilder(); ArrayList arrayList = new ArrayList(); char[] chars ={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; while (a>0){ int index = a % 16; char temp =chars[index]; stringBuilder.append(temp); a = a / 16; } System.out.println(stringBuilder.reverse().toString()); //输出十六进制值 } }
java快速实现十进制转十六进制
最新推荐文章于 2023-05-27 14:55:41 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)