Java decimal string as integer

Suppose you have a string “10.001” and you want to convert it to a primitive integer, first convert the string to a Double, then cast it to an int.


String value = "10.001";
int intValue = (int)Double.parseDouble(value);

Leave a Reply

Your email address will not be published.