I want to make sure I don't pummel the permgen space, so I'm carefully interning my strings.
Are these two statements equivalent ?
String s1 = ( "hello" + "world" ).intern();
String s2 = "hello".intern() + "world".intern();
UPDATE
How I framed my question was totally different from the actual application. Here's the method where I am using intern.
public String toAddress( Transport transport )
{
Constraint.NonNullArgument.check( transport, "transport" );
switch( transport )
{
case GOOGLE:
case MSN:
return ( transport.code() + PERIOD + _domain ).intern();
case YAHOO:
default:
return _domain;
}
}
private String _domain; // is initialized during constructor
private static final String PERIOD = ".";