Exception while converting string to integer
Hello friends,
I am trying to convert string to Int but i am getting exception as java.lang.NumberFormatException: For input string: ""
Code is as follows
String no=request.getParameter(itemno); // here itemno varies everytime...sometime it will be 1 and sometime it will be 2 but in string format
String itemn[]=no.split(" ");
int itemNo=Integer.parseInt(itemn[0]);
Can anyone solve this problem for me??
Thanks in advance
Re: Exception while converting string to integer
Why are you doing the split?
Print out the value of 'no', like:
System.out.println(">" + no + "<");
SO you can spot spaces etc.
Re: Exception while converting string to integer
Re: Exception while converting string to integer
Since OP get the solution he'll never come back, as usual.