Category: java
Datatype and Wrapper Class
Published on 22 Feb 2026
Explanation
int is a primitive data type in Java
that stores 32-bit integer values.
Code:
int a = 10;
Explanation
Integer is a wrapper class that wraps an
int into an object.
Code:
Integer b = 20;
Explanation
int cannot be null, whereas Integer can
store null.
Code:
Integer x = null; // int y = null; // Compilation error
Explanation
Integer provides utility methods like
parseInt() and valueOf().
Code:
int num = Integer.parseInt("100");
Explanation
Autoboxing converts int to Integer
automatically.
Code:
Integer obj = 5; // Autoboxing