Quick Reach
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 in Java and assigns it to a variable.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
public class conversion_example {
public static void main(String []args) {
int a;
double b = 10.41;
a = (int) b;
System.out.println(a);
}
}
|
The output will be:
10
Java int to double conversion example
The example below converts an int to double and assigns it to a variable.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
public class conversion_example {
public static void main(String []args) {
int a=10;
double b;
b = (double) a;
System.out.println(b);
}
}
|
The output will be:
10.0
Also see int to string | string to int
Leave A Comment?