- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoxingUnBoxing.java
More file actions
Latest commit
36 lines (34 loc) · 1.13 KB
/
Copy pathBoxingUnBoxing.java
File metadata and controls
36 lines (34 loc) · 1.13 KB
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
33
34
35
36
packageboxing;
publicclassBoxingUnBoxing {
publicstaticvoidmain(Stringargs[]) {
// Boxing
bytea = 1;
Bytebyteobj = newByte(a);
intb = 10;
Integerintobj = newInteger(b);
floatc = 18.6f;
Floatfloatobj = newFloat(c);
doubled = 250.5;
Doubledoubleobj = newDouble(d);
chare = 'a';
Charactercharobj = e;
System.out.println("Values of Boxed objects (printing as objects)");
System.out.println("Byte object byteobj: " + byteobj);
System.out.println("Integer object intobj: " + intobj);
System.out.println("Float object floatobj: " + floatobj);
System.out.println("Double object doubleobj: " + doubleobj);
System.out.println("Character object charobj: " + charobj);
// UnBoxing
bytebv = byteobj;
intiv = intobj;
floatfv = floatobj;
doubledv = doubleobj;
charcv = charobj;
System.out.println("\nUnBoxed values (printing as data types)");
System.out.println("byte value, bv: " + bv);
System.out.println("int value, iv: " + iv);
System.out.println("float value, fv: " + fv);
System.out.println("double value, dv: " + dv);
System.out.println("char value, cv: " + cv);
}
}