先声明一个静态常量BASE private static final int BASE=16; 为了提高性能,将字符对应的十进制存入map中, 将输入的十六进制取出前面的"0x"后作为数值 num, 遍历获取的数值,将其转为char数组, 再采用map获取每个char对应的值: private static Map<Character, Integer> map = new HashMap<Character, Integer>() { { put('0', 0); put('1', 1); put('2', 2); put('3', 3); put('4', 4); ...