The argument might be that the "abc" caused creation of an interned String - an argument that I disagree with. It just goes to show that Strings are not good for use in "how many objects" questions. Bill
The explanation given is as follows: Objects created at runtime are not placed in the constant pool, while the literal String "abc" is placed there. Therefore, three objects are created. One, the String "abc", is created at class load time; the other two are StringBuffer objects created at the time the code is executed.
No objects are created by the compiler. No objects live in the constant pool. All objects are created at runtime and inhabit the heap. String objects that are interned happen to be referenced from the String pool. The String pool is not the constant pool of a class. The String object pointed to by a string literal is created the first time such literal is used, and interned. Subsequent string literals with the same content are pointing to such String object. It is like magic ! [ September 15, 2003: Message edited by: Jose Botella ]