Results 1 to 2 of 2
  1. #1
    venkatallu is offline Member
    Join Date
    Sep 2008
    Rep Power

    Default NumberFormatException raised

    hi,iam converting string to integer using Integer.parseInt().
    But it is giving NumberFormatException.Can any help me by
    seeing below code.

    String s="venkat";
    int i=Integer.parseInt(s);
    }catch(NumberFormatException e)
    System.out.println("NumberFormatException: " + e.getMessage());

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    Java Code:
    String s="venkat";
    int i=Integer.parseInt(s);
    what integer is "venkat"? What number would you expect to see for this string?
    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

  1. XML JDOM XPATH NumberFormatException
    By Jazzperson in forum Advanced Java
    Replies: 3
    Last Post: 03-08-2009, 09:15 PM
  2. Exception java.lang.NumberFormatException
    By vasavi.singh in forum New To Java
    Replies: 3
    Last Post: 02-24-2009, 07:27 AM
  3. NumberFormatException problem
    By bluebarca in forum New To Java
    Replies: 1
    Last Post: 02-06-2009, 08:39 AM
  4. Error: NumberFormatException
    By coco in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 07:41 AM
  5. java.lang.NumberFormatException: null
    By Eric in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 07-05-2007, 05:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts