Results 1 to 2 of 2
Thread: NumberFormatException raised
- 06-02-2009, 09:20 PM #1
Member
- Join Date
- Sep 2008
- Posts
- 16
- Rep Power
- 0
NumberFormatException raised
hi,iam converting string to integer using Integer.parseInt().
But it is giving NumberFormatException.Can any help me by
seeing below code.
try{
String s="venkat";
int i=Integer.parseInt(s);
System.out.println(i);
}catch(NumberFormatException e)
{
System.out.println("NumberFormatException: " + e.getMessage());
-
what integer is "venkat"? What number would you expect to see for this string?Java Code:String s="venkat"; int i=Integer.parseInt(s);
Wouldn't it make much more sense to try to parse a number string to int? Something like,
Java Code:String s="123"; int i=Integer.parseInt(s);
Last edited by Fubarable; 06-02-2009 at 09:30 PM.
Similar Threads
-
XML JDOM XPATH NumberFormatException
By Jazzperson in forum Advanced JavaReplies: 3Last Post: 03-08-2009, 08:15 PM -
Exception java.lang.NumberFormatException
By vasavi.singh in forum New To JavaReplies: 3Last Post: 02-24-2009, 06:27 AM -
NumberFormatException problem
By bluebarca in forum New To JavaReplies: 1Last Post: 02-06-2009, 07:39 AM -
Error: NumberFormatException
By coco in forum New To JavaReplies: 1Last Post: 08-07-2007, 07:41 AM -
java.lang.NumberFormatException: null
By Eric in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 07-05-2007, 05:31 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks