In Java the boxing range for any integer is between -128 and 127. So whenever you use numbers in this specified range, you can compare it with the “==” operator. But for Integer objects outside the range you can only use equals.
Autoboxing in Java is converting a primitive value into an object of the corresponding wrapper class eg. Converting int to integer class.
Unboxing in Java refers to converting an object of a wrapper type to its corresponding primitive value eg. Conversion of Integer to int.
Here is an illustration of autoboxing and unboxing:
1. import java.io.*;
2. import java.util.*;
3. class Integer_Boxing
5. public static void main (String args)
7. List<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < 10; i++)
In the above example we are including int primitive types rather than Integer Object.
Hope this helps!!