Results 1 to 6 of 6
  1. #1
    Thibisan is offline Member
    Join Date
    May 2012
    Posts
    2
    Rep Power
    0

    Default Converting string to integer

    Hi,
    I was wondering if anyone can help me with a problem.
    The user will be entering W=123,H=1234,L=12345. This will all be string and i need to figure out how to get those three numbers to int so i can find the volume. Can anyone help me?

  2. #2
    doWhile is online now Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,606
    Rep Power
    5

    Default Re: Converting string to integer

    See the API for the Integer class, in particular the parseInt method

  3. #3
    Thibisan is offline Member
    Join Date
    May 2012
    Posts
    2
    Rep Power
    0

    Default Re: Converting string to integer

    Im still not sure what to do and am a little confused. Can you please elaborate?

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Moderator
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    9,918
    Rep Power
    16

    Default Re: Converting string to integer

    See the API for the Integer class, in particular the parseInt method

    db
    Why do they call it rush hour when nothing moves? - Robin Williams

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    10,460
    Rep Power
    16

    Default Re: Converting string to integer

    If the user is typing this in (on a single line):
    W=123,H=1234,L=12345
    you will also need to split the String based on the commas.
    You'll need to look at the other String methods to then find the integer part of (eg)
    W=123
    Then you can use the links given above to turn that into an int.
    Please do not ask for code as refusal often offends.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Moderator
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    9,918
    Rep Power
    16

    Default Re: Converting string to integer

    Moved from Advanced Java. Please don't post beginner questions in that section.

    db
    Why do they call it rush hour when nothing moves? - Robin Williams

Similar Threads

  1. Exception while converting string to integer
    By bharatgs7 in forum New To Java
    Replies: 3
    Last Post: 01-11-2012, 05:06 AM
  2. Converting J001 to integer
    By jaylimix in forum New To Java
    Replies: 4
    Last Post: 12-15-2011, 11:08 PM
  3. Replies: 2
    Last Post: 11-27-2011, 05:11 PM
  4. Converting a 2's complement to the proper integer
    By Chuklol in forum New To Java
    Replies: 1
    Last Post: 10-10-2011, 05:47 AM
  5. Converting an integer into a BigInteger
    By mzjazzygirl in forum New To Java
    Replies: 27
    Last Post: 09-23-2010, 06:37 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
  •