|
How to convert a string to a number |
|
|
This Java tip illustrates a method of converting a string to a number. This tip is very useful
for developer who are expecting a number as a input but recieve the number in a string format.
Developers may use this code to convert the retrieved string into number format.
byte b = Byte.parseByte("123");
short s = Short.parseShort("123");
int i = Integer.parseInt("123");
long l = Long.parseLong("123");
float f = Float.parseFloat("123.4");
double d = Double.parseDouble("123.4e10");
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.