有关java.lang.NumberFormatException:null的问题Whether the price you give is rightRan)//if(Integer.parseInt(price)>Integer.parseInt(Ran)){out.println("a litle larger");out.println("");flag=1;session.setAttribute("flag","flag");}if(Price运行上

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/09 12:33:20
有关java.lang.NumberFormatException:null的问题Whether the price you give is rightRan)//if(Integer.parseInt(price)>Integer.parseInt(Ran)){out.println(

有关java.lang.NumberFormatException:null的问题Whether the price you give is rightRan)//if(Integer.parseInt(price)>Integer.parseInt(Ran)){out.println("a litle larger");out.println("");flag=1;session.setAttribute("flag","flag");}if(Price运行上
有关java.lang.NumberFormatException:null的问题
Whether the price you give is right


Ran)
//if(Integer.parseInt(price)>Integer.parseInt(Ran))
{
out.println("
a litle larger
");
out.println("");
flag=1;
session.setAttribute("flag","flag");
}
if(Price

运行上面代码会出现java.lang.NumberFormatException:null,

有关java.lang.NumberFormatException:null的问题Whether the price you give is rightRan)//if(Integer.parseInt(price)>Integer.parseInt(Ran)){out.println("a litle larger");out.println("");flag=1;session.setAttribute("flag","flag");}if(Price运行上
问题应该就出在那你那个:Integer.parseInt(变量)上,
从报错来说,应该是括号里面的“变量”是null,当然也就无法转换为Integer类型了.
建议你检查一下这几行代码:
1、flag = Integer.parseInt(flag1); //flag1为null,就会报你说的错误
2、int Price= Integer.parseInt(price); //price为null,就会报你说的错误
反正有Integer.parseInt()的地方都看一看,parseInt()方法括号里面的不能是null,也不能是其他无法转换为数字的字符串