forked from maheshashokit/27_Java_Full_Stack_Repo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectToPrimitive.java
More file actions
30 lines (23 loc) · 852 Bytes
/
ObjectToPrimitive.java
File metadata and controls
30 lines (23 loc) · 852 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
public class ObjectToPrimitive {
public static void main(String[] args) {
//Wrapper class object
Integer i1 = 10;
Float f1 = 10.2589f;
Double d1 = 23.6589d;
//1.By calling instance method of respective wrapper classes
int intValue = i1.intValue();
float floatValue = f1.floatValue();
double doubleValue = d1.doubleValue();
System.out.println("int value:::::" + intValue);
System.out.println("float value:::::" + floatValue);
System.out.println("double value:::::" + doubleValue);
System.out.println("*********************************************");
//2 Performing Auto UnBoxing
int a = i1;
float b = f1;
double d = d1;
System.out.println("int value:::::" + a);
System.out.println("float value:::::" + b);
System.out.println("double value:::::" + d);
}
}