Java进制转换练习
程序员文章站
2024-03-17 13:29:58
...
二进制转十六进制
import java.math.BigInteger;
import java.util.Scanner;
public class TestString {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
String str = sc.next();
BigInteger bit = new BigInteger(str, 2);
String str1 = bit.toString(16).toUpperCase();
System.out.println(str1);
}
}
}
下一篇: javascript学习笔记之正则表达式