Convert Double to Integer in Java



At first, initialize a double value −

double val = 978.65;

Now, convert the Double to Integer value using intValue() method −

Double d = new Double(val); int res = d.intValue();

Example

Following is the program to convert Double to Integer in Java −

public class Demo {    public static void main(String args[]) {       double val = 978.65;       System.out.println("Double = "+val);       Double d = new Double(val);       int res = d.intValue();       System.out.println("Double to Integer value = "+res);    } }

Output

Double = 978.65 Double to Integer value = 978
Updated on: 2019-09-25T08:40:49+05:30

781 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements