Results 1 to 2 of 2
  1. #1
    lisa.abraham is offline Member
    Join Date
    Jul 2012
    Posts
    7
    Rep Power
    0

    Default Need help regarding String to int Conversion

    in Java when we use parseInt(String) how can we chck that if the String has only the numbers, or it contains any character too. is there any sort of function or we have to chck every index separately ?

    cross posted at

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,360
    Blog Entries
    7
    Rep Power
    20

    Default Re: Need help regarding String to int Conversion

    Quote Originally Posted by lisa.abraham View Post
    in Java when we use parseInt(String) how can we chck that if the String has only the numbers, or it contains any character too. is there any sort of function or we have to chck every index separately ?
    Let that same parseInt( ... ) method do the job, i.e. if your String contains non-digit characters that method throws a NumberFormatException; all you have to do is catch it and do what you have to do.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. string to integer conversion
    By boys21 in forum New To Java
    Replies: 3
    Last Post: 10-17-2011, 03:58 PM
  2. String to Hex Conversion
    By mocha in forum New To Java
    Replies: 0
    Last Post: 03-17-2010, 08:45 AM
  3. String Conversion....
    By hotice1027 in forum New To Java
    Replies: 8
    Last Post: 11-28-2008, 10:52 PM
  4. String to Object conversion
    By moaxjlou in forum New To Java
    Replies: 1
    Last Post: 10-29-2008, 01:04 AM
  5. string conversion??
    By j2vdk in forum New To Java
    Replies: 13
    Last Post: 09-19-2008, 03:35 PM

Posting Permissions

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