Though we move ahead with Java versions, why are we maintaining support of primitives ( which are not objects consitituting to not making 100% OOP language ).
Wrapper classes around the primitives comes with support of auto boxing & unboxing as well.
Few main reasons I could think of are :
Though conversion happens automatically with (un)boxing support, behind the scenes it still does run
.intValue()
to get its associated primitive value to perform calculation & then stores back to its corresponding Integer object.Integer a=3,b=5;
// Below will do a.intValue()+b.intValue() & then store/display, if I am correct.
System.out.println(a+b);
And also using wrapper class objects consumes heap space as opposed to performing arithematic operations using primitives on stack space.
- I read something stating : its for support of some Enumeration classes as a backward compatibility reason?
Is above listed reasons not leading to non-elimination / making deprecated on primitives usage?.