Amazon Interview Question
Development Support EngineersI agree with all above reasons but the main reason i think that makes the presence of Integer justified is its use in generics. How will otherwise you use int in an ArrayList or HashMap when you have no equals() or hashcode() method associated with it (since int is primitve and do not extend Object)
definitely....to make primitive data types as other class-objects..........an OOPs feature of java
agreed with anshulzunke.
there were no primitive data types in the very first version of Java but this made the java language very slower, because it is expensive to have even the numbers in the object form.
That is when 'primitive data types' were introduced, which is why we can not say java is 100% object-oriented language.
I said int is a primitive data type and Integer is a wrapper class around it. The need for Integer is to have methods on the primitive data type like say conversion of an String to integer we user Integer.parseInt()
- perllove January 19, 2008