-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWrappers.java
More file actions
34 lines (27 loc) · 1008 Bytes
/
Wrappers.java
File metadata and controls
34 lines (27 loc) · 1008 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
33
34
public class Wrappers {
public static void main(String[] args) {
// wrapper class = provides a way to use primitive data types as reference date types
// reference data types contain useful methods
// can be used with collections (ex. ArrayList)
// reference data types can be slower to access
//primitive //wrapper
//--------- //--------
//boolean //Boolean
//char //Character
//int //Integer
//double //Double
//autoboxing = the automatic conversion that the java compiler makes between the primitive their
// corresponding wrapper class ie: int to Integer
//autoboxing example int to Integer
//unboxing = reverse of autoboxing. Automatic conversion of wrapper class to primitive
Boolean a = true;
Character b = '@';
Integer c = 123;
Double d = 3.14;
String e = "Bro";
//Even though reference data type, will still behave as a primitive due to autoboxing
if(a==true) {
System.out.println("This is true");
}
}
}