Possible Duplicate:
New Integer vs valueOf
I read at few place that Integer.valueOf is better than new Integer(), since it allows caching of values to be done by the compiler. So when should I be using new Integer() and not Integer.valueOf(). Is there a reason/scenario where I should not be using Interger.valueOf()
Thanks
No, there is no scenario where new Integer()
should be used. If you are distinguishing integers by their wrapper object identity then you are not likely to be doing something reasonable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With