Can we call a primitive wrapper class as a reference type after boxing ?
I'm also aware of AtomicInteger
, AtomicLong
, AtomicBoolean
and AtomicReference<V>
are mutable.
Integer age = new Integer(23);
Integer old = age;
System.out.println("Age : "+age);
System.out.println("Old : "+ old);
System.out.println("*************");
age = 24;
System.out.println("Age : "+age);
System.out.println("Old : "+ old);
Result
Age : 23
Old : 23
After update ****
Age : 24
Old : 23
I agreed that primitive and its wrappers are immutable. But what is the meaning\purpose of boxing here?
Copied from Wikipedia:
Boxing, otherwise known as wrapping, is the process of placing a primitive type within an object so that the primitive can be used as a reference object.