+ 1

What is the difference between Int and Integer ?

15th Dec 2016, 11:51 AM
زياد وجدي
زياد وجدي - avatar
4 Réponses
+ 2
integer is the full name
15th Dec 2016, 12:13 PM
pocholin
pocholin - avatar
+ 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.
15th Dec 2016, 12:50 PM
Ettienne Gilbert
Ettienne Gilbert - avatar
+ 2
Thanks Kornhe !
15th Dec 2016, 1:47 PM
زياد وجدي
زياد وجدي - avatar
+ 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 .
15th Dec 2016, 1:46 PM
زياد وجدي
زياد وجدي - avatar