我试过了:
int amount = 5;
String amountStr = "0x0" + amount;
byte newByte = Byte.parsByte(amountStr);
Run Code Online (Sandbox Code Playgroud)
但我明白了java.lang.NumberFormatException: For input string: "0x05".
如果要解析String,请使用Byte#decode:
byte newByte = Byte.decode(amountStr);
Run Code Online (Sandbox Code Playgroud)
否则你可以投它(如评论中所写).
| 归档时间: |
|
| 查看次数: |
2077 次 |
| 最近记录: |