22 May, 2014

What is the difference between primitive and Wrapper Classes?

  1. Primitives are not objects
  2. We cannot perform any function on primitives
  3. Primitives are stored on Stack, Wrapper Objects are stored on heap
  4. primitives store value where as objects store a reference to actual objects. (References are not present for primitives)
  5. since primitives are stored on stack, the will be garbage collected once their visibility is over. Objects on other hand are present on heap, so their Garbage collection decision making is a bit complex.
  6. Wrapper Class Integer create final objects where as the value of int is modifiable.