看看int a和int b在十六进制值之前如何具有前缀"0x"?我想从一个字符串中做更多这些.我试图使用Integer的parseInt,但是我得到了一个NumberFormatException.有人可以帮忙吗?
int a = 0xA;
int b = 0x4;
String f = "0xF";
int d = Integer.parseInt(f, 16);
Run Code Online (Sandbox Code Playgroud)
我想要"int d = 0xF"
这个怎么样?
String f = "0xF";
int d = Integer.parseInt(f.substring(2), 16);
System.out.println(d);
Run Code Online (Sandbox Code Playgroud)
OUTPUT:
15
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2602 次 |
| 最近记录: |