Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
36 lines (34 loc) · 1.13 KB

File metadata and controls

36 lines (34 loc) · 1.13 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package boxing;
public class BoxingUnBoxing {
public static void main(String args[]) {
// Boxing
byte a = 1;
Byte byteobj = new Byte(a);
int b = 10;
Integer intobj = new Integer(b);
float c = 18.6f;
Float floatobj = new Float(c);
double d = 250.5;
Double doubleobj = new Double(d);
char e = 'a';
Character charobj = 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
byte bv = byteobj;
int iv = intobj;
float fv = floatobj;
double dv = doubleobj;
char cv = 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);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.