-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractice.java
More file actions
32 lines (22 loc) · 770 Bytes
/
practice.java
File metadata and controls
32 lines (22 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.util.*;
class practice {
public static void main(String[] args){
//narrowing conversion from wrapper to primitive
Double d = 134343d;
long l;
l = (long)(double)d;
System.out.println(l);
l = (long)d.doubleValue();
System.out.println(l);
l = d.longValue();
System.out.println(l);
//cast from double to Long
double d1 = 34;
Long l1 = (long)d1; //cast it to primitive long and assign to Long. Auto-boxing will take care after that
/**
* For cast from Double to byte/short/int/long/double we have .byte/short/int/long/doubleValue() method.
* For laborious one see down
*/
l = (long)(double)d;
}
}