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: 25-Sep-2019

647 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements