You need to explicitly get the int value using method intValue() like this:

CopyDouble d = 5.25;
Integer i = d.intValue(); // i becomes 5

Or

Copydouble d = 5.25;
int i = (int) d;
Answer from anubhava on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ convert-double-to-integer-in-java
Convert Double to Integer in Java - GeeksforGeeks
class GFG { public static void main(String[] args) { double data1 = 3452.345; System.out.println("Double : " + data1); int value1 = (int) Math.round(data1); System.out.println("Integer : " + value1); double data2 = 3452.765; System.out.println("\nDouble : " + data2); int value2 = (int) Math.round(data2); System.out.println("Integer : " + value2); } }
Published ย  December 20, 2025
๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ java โ€บ examples โ€บ convert-double-type-variables-to-int
Java Program to convert double type variables to int | Vultr Docs
December 9, 2024 - double myDouble = 9.78; int myInt = (int) myDouble; System.out.println("Converted value: " + myInt); Explain Code ยท This snippet directly casts myDouble to an int. The decimal part (.78) is truncated, and the result is simply 9. Sometimes, a simple cast isn't sufficient, especially in situations where rounding the double to the nearest integer might be necessary. Java's Math class provides several methods that can be used for these purposes.
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ home โ€บ java/lang โ€บ java double value method
Java Double Value Method
September 1, 2008 - This method returns the double value after conversion. The following example shows the usage of Java Number doubleValue() method. Here, we are instantiating an Integer object and initializing it. The method is then invoked on this object.
๐ŸŒ
Edureka
edureka.co โ€บ blog โ€บ double-to-int-in-java
How to convert Double to Integer in Java? Edureka
November 27, 2019 - Next, let us see how to convert Double to Int in Java, by using the math.round() method. This method is used to round the Double value to the nearest integer.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ java-number-doublevalue-method
Java Number.doubleValue() Method - GeeksforGeeks
May 15, 2025 - Example 1: In this example, we are going to convert Integer and Float into double using Number.doubleValue() method. ... // Java program to demonstrate the // use of doubleValue() method import java.lang.Number; public class Geeks { public static ...
Find elsewhere
๐ŸŒ
Software Testing Help
softwaretestinghelp.com โ€บ home โ€บ java โ€บ 3 methods to convert double to int in java
3 Methods To Convert Double To Int In Java
April 1, 2025 - Here, the โ€œ99.95โ€ value is assigned to double variable billAmt. ... This is converted to an integer by downcasting to an int data type as shown below.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ integer-doublevalue-method-in-java
Integer doubleValue() Method in Java - GeeksforGeeks
July 7, 2018 - The doubleValue() method of Integer class of java.lang package is used to convert the value of the given Integer to a Double type after a widening primitive conversion and returns it.
๐ŸŒ
Blogger
javarevisited.blogspot.com โ€บ 2017 โ€บ 01 โ€บ how-to-convert-double-to-int-in-java.html
How to convert double to int in Java? Example
The simplest way to convert double to int in Java is by downcasting it. This will return you the non-fractional part of the number as an int, but it doesn't do rounding, so even 9.999 will be converted to 9. If you are looking to convert double ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ java-program-to-convert-int-to-double
Java Program to Convert Int to Double - GeeksforGeeks
January 21, 2025 - Double class in Java is a wrapper ... with double matters. Int value can be passed to the constructor of the Double class to create an object of double type initialized with provided integer value....
๐ŸŒ
Oracle
docs.oracle.com โ€บ en โ€บ java โ€บ javase โ€บ 24 โ€บ docs โ€บ api โ€บ java.base โ€บ java โ€บ lang โ€บ Double.html
Double (Java SE 24 & JDK 24)
July 15, 2025 - This representation hazard of decimal fractions is one reason to use caution when storing monetary values as float or double. Alternatives include: using BigDecimal to store decimal fractional values exactly ยท scaling up so the monetary value is an integer โ€” for example, multiplying by 100 if the value is denominated in cents or multiplying by 1000 if the value is denominated in mills โ€” and then storing that scaled value in an integer type
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java numbers โ€บ check if a double is an integer in java
Check if a double Is an Integer in Java | Baeldung
January 24, 2024 - In this test, we assign 2.0D * Integer.MAX_VALUE to the double d3. Obviously, this value is a mathematical integer but out of Javaโ€™s integer range.
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ how-to-convert-a-double-to-int-in-java
How to convert a double to int in Java
All the digits after the decimal are lost and x holds the integer ... Since double is a bigger data type than int, it needs to be down-casted. See the syntax below: ... 0.50.5 to the value and truncating its decimal points. The long value can then be converted to an int using typecasting. ... The code snippet below illustrates the usage of Math.round() when converting a double data type to an int in Java:
๐ŸŒ
BeginnersBook
beginnersbook.com โ€บ 2018 โ€บ 09 โ€บ java-convert-double-to-int
Java double to int Conversion
double myDouble = 9.99; int myInt = (int) myDouble; System.out.println(myInt); // Output: 9 ยท If you want the nearest integer as output, you can use Math.round() method. This method returns a long value so you need to cast it to convert it into an int.
๐ŸŒ
MIT
web.mit.edu โ€บ java_v1.0.2 โ€บ www โ€บ javadoc โ€บ java.lang.Double.html
Class java.lang.Double
Returns the float value of this Double. ... Returns a hashcode for this Double. ... Returns the integer value of this Double (by casting to an int).