SE450
:
Converting Strings to Numbers
[35/53]
Use static methods
Integer.parseInt
Double.parseDouble
Example:
String input = "7";
int n = Integer.parseInt(input);
// yields integer 7
If string doesn't contain a number, throws a
NumberFormatException
(unchecked)