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 offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    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 Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Converting string to integer

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

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    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.

    ** This space for rent **

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Converting string to integer

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

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

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