1
我想:如何在Java中將(int)5轉換爲(byte)0x05?
int amount = 5;
String amountStr = "0x0" + amount;
byte newByte = Byte.parsByte(amountStr);
,但我得到java.lang.NumberFormatException: For input string: "0x05"
。
我想:如何在Java中將(int)5轉換爲(byte)0x05?
int amount = 5;
String amountStr = "0x0" + amount;
byte newByte = Byte.parsByte(amountStr);
,但我得到java.lang.NumberFormatException: For input string: "0x05"
。
'newByte =(byte)amount'? – 2012-04-19 17:14:29