Data types
Primitive data types
- int
- boolean
- char
- double
Reference data types / Wrapper classes
- Integers
- Boolean
- Character
- Double
- String
- Primitive types are faster and useful in calculations involving huge numbers
- Reference data types by using Wrapper classes allow access to useful methods like e. g
String str = "Hello";
System.out.println(str.Length);Autoboxing
Process in which the java compiler converts the primitive data type to a reference data type in cases such as Assignment of a reference data type
Integer num = 15;
String str = "@";Unboxing
The process where the java compiler converts the Reference data type converts the Reference data type to its primitive data value when the value has to be used in calculations or check conditionals
Boolean b = true;
if(b==true){
System.out.println("True);
}