java.lang.NumberFormatException: Invalid int: "18DA10FA"
this.iso15765 = new ISO15765(Integer.parseInt(request_can_id,16), Integer.parseInt(response_can_id,16));
18DA10FA转换为Int类型的时候,要添加参数16,否则会报错
1,正确写法:
String str="A5";
int bb = 0;
try{
bb=Integer.valueOf(str,16).intValue();
}catch(NumberFormatException ee){
ee.printStackTrace();
}
System.out.print(bb);
打印:165
2,错误写法:
String str="A5";
int bb = 0;
try{
bb=Integer.valueOf(str).intValue();
}catch(NumberFormatException ee){
ee.printStackTrace();
}
System.out.print(bb);
打印:
java.lang.NumberFormatException: For input string: "A5"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.valueOf(Integer.java:766)
at Test.main(Test.java:16)
网友评论