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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Stupidly simple Java question

  • 06-12-2004 5:13pm
    #1
    Moderators, Music Moderators Posts: 23,363 Mod ✭✭✭✭


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

    string1 = "1"
    int1 = 1

    ???


Comments

  • Registered Users, Registered Users 2 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,363 Mod ✭✭✭✭feylya


    Excellent. Cheers. My mind just went blank.


  • Registered Users, Registered Users 2 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, Registered Users 2 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