Join 500+ Software Testing professionals. Solve problem and get your problem solved. Register Now!

0
convert string with decimal to integer

Solved 1 Answers 189 Views Programming
0 1
I am given a string (100.0). I need to convert that to int. How do I do that?

When I do Integer.parseInt(). I am getting below error.

java.lang.NumberFormatException: For input string: "100.0"

1 Answer

0
Best answer
0

You can achieve this by using java.lang.Double class

 

Double valueToDouble = Double.parseDouble("100.0");
int valueint = valueToDouble .intValue();
answered by

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
...