看看int a和int b如何在十六进制值之前具有前缀“ 0x”?我想从字符串中获取更多信息。我尝试使用Integer中的parseInt,但收到NumberFormatException。有人可以帮忙吗?
int a = 0xA;
int b = 0x4;
String f = "0xF";
int d = Integer.parseInt(f, 16);
我想要“ int d = 0xF”
最佳答案
这个怎么样?
String f = "0xF";
int d = Integer.parseInt(f.substring(2), 16);
System.out.println(d);
输出:
15