Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Stupidly simple Java question

  • 06-12-2004 05:13PM
    #1
    Moderators, Music Moderators Posts: 23,365 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,365 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