jdg
jdg

Reputation: 11

Java, How to convert decimal number as string into an integer

I have a text file with decimal numbers in it. I am trying to use Integer.valueOf() in a Java program and it does not convert the decimal numbers.

How do I convert the decimal number string into an int?

Upvotes: 0

Views: 12604

Answers (1)

Bathsheba
Bathsheba

Reputation: 234875

You can use java's Double.valueOf() defined here instead; then you can convert the resulting double to an int.

Upvotes: 2

Related Questions