Remember that the JVM was created to reduce the code size for embedded devices (mostly) - it is an operating system with a prefix. I worked on several built-in java platforms, and in cases where the value of valueOf would be more obvious, in some cases this will save a little space.
Basically, the method exists because the βnewβ can never use cached instances. valueOf MAY be implemented to use cached instances (otherwise you will always use the new one) and probably does everything that saves time.
If they (or you) replaced this method with the one that really did the cache values, then all of your code could take advantage of this change, but without preparation using a method like "valueOf", this will never happen (well, almost never - you could tweak the compiler / bytecode executor to have "new" returned cached values, but I think this will break some contracts)
So cache is not a lie, but only a state of mind.
Bill K Dec 19 '11 at 17:01 2011-12-19 17:01
source share