Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Stupidly simple Java question

Options
  • 06-12-2004 6:13pm
    #1
    Moderators, Music Moderators Posts: 23,361 Mod ✭✭✭✭


    How do you convert a string to an int? ie, get the value of the string:

    string1 = "1"
    int1 = 1

    ???


Comments

  • Registered Users Posts: 10,148 ✭✭✭✭Raskolnikov


    feylya wrote:
    How do you convert a string to an int? ie, get the value of the string:

    string1 = "1"
    int1 = 1

    ???
    int int1 = Integer.parseInt(string1);


  • Moderators, Music Moderators Posts: 23,361 Mod ✭✭✭✭feylya


    Excellent. Cheers. My mind just went blank.


  • Registered Users Posts: 10,148 ✭✭✭✭Raskolnikov


    feylya wrote:
    Excellent. Cheers. My mind just went blank.
    Always check the Java docs, if you think that there's a method to do what you want, in all likelyhood, it'll be there.


  • Registered Users Posts: 568 ✭✭✭phil


    For the simple types, e.g. int, char, double etc. there are proper Object representations in the API.

    e.g. int - Integer, double - Double

    Manipulations of these simple types can normally be performed with static methods in these classes.

    Regards,

    Phil.


Advertisement