a quick question about String

Raffaello Giulietti raffaello.giulietti at gmail.com
Sat Jan 1 19:59:35 UTC 2022


Hello,

the simple answer is that
	new String(...) == new String(...)
*never* evaluates to true )it might throw, though), whatever 
constructors you are using and whatever arguments you pass to to them.

Some garbage collectors *might* de-duplicate the underlying arrays (but 
you cannot tell), but the references to the Strings will be different.


HTH
Raffaello


On 2021-12-23 18:59, Alan Snyder wrote:
> Do the public constructors of String actually do what their documentation says (allocate a new instance), or is there some kind of compiler magic that might avoid allocation?
> 


More information about the core-libs-dev mailing list