Originally posted by Preetha Arun: valueOf() returns newly createdobject of the type that invoked the method.
No value of returns objects from the pool. when you use new Type() syntax, then you get a new object. In autoboxing you get a value from the pool(it it's in the range) because autoboxing uses type.valueOf internally...
"valueOf" methods are static factory methods. They provide an alternative mechanism for instatiating objects (they are used in a number of places including the wrapper classes). One of their benefits is that they allow the flexibility to determine whether a new instance is created or whether a reference to a previously created instance (from a previosly allocated pool) is returned (this is being an implementation of the Flyweight pattern). In this example the boolean Wrapper class (Boolean) can return the same reference when invoked with Boolean.value("true") without the need to actually create an new object each time. Depending on the exact nature of the program this can potentially add up to a very singificant saving in memory. It is certainly a value tool to understand and apply prudently when your putting Java to work (for more info see Effective Java).
(P.S. I found that understanding the context helped me to remember what valueOf methods took as parameters and what types they returned)