2 demos of converting Java int to double and double to int

Java double to int conversion

You may convert the variable of data type double to int and int to double quite easily in Java programming. The example below shows how to convert that.

A double to int conversion example

The example below converts a double to int type and assigns it to a variable. Finally, the value of the variable after the conversion is displayed:

The output will be:

10

Java int to double conversion example

The example below converts an int type variable to double and assigns it to a variable. Have a look at the code and output after conversion:

The output will be:

10.0

Related: