previous |
start |
next .... [Slide 36] ....
Converting Strings to Numbers
- 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)
previous |
start |
next .... [Slide 36] ....