Jeff Nowakowski wrote:
On 02/06/2011 05:43 AM, Jacob Carlborg wrote:
On 2011-02-04 21:44, Jeff Nowakowski wrote:

Java's substring() does not copy the text, at least in the official JDK
implementation. Unfortunately, it doesn't specify this behavior as part
of the String API.

But, I assume, it will allocate a new instance of String even though the
content point to the same data?

Yes, but small objects in Java are very fast to allocate and garbage collect.

It's even faster to not allocate/collect at all! That's the advantage of proper slices.

Reply via email to