Selvin Selvin - 2 years ago 129
Java Question

How to convert Double to int directly?

May be this is silly question. I want to get rid of the fractional part of the

number. But I cant do that. It shows the error that incompatible types. What to do?

Double to int
conversion in one line....please help thanks

Answer Source

If you really should use Double instead of double you even can get the int Value of Double by calling:

Double d = new Double(1.23);
int i = d.intValue();

Else its already described by Peter Lawreys answer.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download