Logo

Programming-Idioms

History of Idiom 22 > diff from v86 to v87

Edit summary for version 87 by programming-idioms.org:
Restored version 85

Version 86

2019-12-13, 09:06:29

Version 87

2019-12-16, 09:05:33

Idiom #22 Convert string to integer

Extract integer value i from its string representation s (in radix 10)

Illustration

Idiom #22 Convert string to integer

Extract integer value i from its string representation s (in radix 10)

Illustration
Extra Keywords
int base conversion
Extra Keywords
int base conversion
Code
int i = Integer.parseInt(s);
Code
int i = new Integer(s).intValue();
Comments bubble
This will throw NumberFormatException if s does not contain a parsable integer
Comments bubble
This will throw NumberFormatException if s does not contain a parsable integer
Doc URL
https://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html#parseInt(java.lang.String)
Doc URL
https://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html#Integer%28java.lang.String%29