+ 1
What is the difference between Int and Integer ?
4 Réponses
+ 2
integer is the full name
+ 2
According to the previous answer "integer is the full name"... I guess that is true, but it tells you very little!
A more important difference is this:
int is the built-in native type - what is known as a POD ("plain-old-data") type. Integer, on the other hand, is more-or-less a class wrapper around the native int.
The reason this is required in Java is that only Object derived classes can be stored in Collections (linked lists, vectors, etc). And native ints are not classes (and hence not derived from Object). So this Object-derived-class-wrapper is required to allow ints to be stored in Collections.
+ 2
Thanks Kornhe !
+ 1
Ettienne : that's it yeah , I knew the full name for sure :D
I noticed it has been used with Lists and HashMap also , so I had that question .
thanks a lot for your reply .