Thanks. I think I still have doubts on that, but will study and let you know if there is anything I need to understand.Still weak on the concepts of Autoboxing.
Take Care.
The future belongs to those who believe in the beauty of their dreams.Dream BIG!
Yes, whether created with "new" or with autoboxing, an Integer instance is an object on the heap. You don't need to say "new" because autoboxing automatically takes care of instantiating the object for you.
But one important difference is that autoboxing will not always create a new object. If the value is within the range of a byte (-128 to 127), then the boxed instances are "pooled." If the "pool" already contains a wrapped instance of that value, then autoboxing will return a reference to the pooled instance instead of creating a new object.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Thanks. Can you please clear me about the concept of pooliing. From what I gathered, Pooling is used to save memory and instead of creating a new object it looks for an object with the same value and creates a reference to it instead of creating a new one. But what happens if there are no objects of that kind on the heap? And what exactly do you mean by having and object on the pool.
The future belongs to those who believe in the beauty of their dreams.Dream BIG!
If you want to look young and thin, hang around old, fat people. Or this tiny ad:
Gift giving made easy with the permaculture playing cards