IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New A few points about this
If Java was a decent OO language you would just do:
String s = "10";
Integer i = new Integer(s);

However because of the fact that Java has the primitive - Object dichotomy and Integer's in Java are useless Objects you need to get the intValue from the Integer. You could do the following:
String s = "10";
int i = new Integer(s).intValue();

however, all this really does is call Integer.parse

A number of other points:

You don't need to import java.lang.*
Integer.parseInt(s);
will throw a NumberFormatException, therefore if you are accepting input from a text field you should probably catch this exception (in case the user entered characters and not numbers).
New Actually
If Java were a decent OO language you would just say something like:

int i = aString.toInt()

which would make it a little consistent with toString() which is everywhere.

Its not though. The incredible number of stupid inconsistencies in core api make Java the dogs bollocks to work with as you spend more time searching around for how to do something than just doing it.
     String conversion to int in Java? - (inthane-chan) - (8)
         Some code here. - (Another Scott) - (1)
             I don't believe it. - (inthane-chan)
         Look in the Integer class? - (ChrisR) - (1)
             Thanks. - (inthane-chan)
         Another example. - (Another Scott)
         Easy enough - (wharris2) - (2)
             A few points about this - (bluke) - (1)
                 Actually - (tuberculosis)

Golden Service, Incorporated
35 ms