Hi John,
In the link I had suggested jim has provided a link to JLS (
here). So if u go there and read u will find following statement.
Strings computed by constant expression (�15.27) are computed at compile time and then treated as if they were literal.
If we go through the example provided by jim
String a = "Bill"; // String constant
String b = "Gates"; // String constant
String b = "Bill" + "Gates"; // String constant
String d = a + b; // not a String constant
See last statement is not a String literal because it is not a
String constant expression.Result is not known at compile time because it is based on variables. However if we change the example little bit and make both the variables as final variable
final String a = "Bill"; // String constant
final String b = "Gates"; // String constant
String d = a + b; // this *is* a String constant
See Now last statement is a String literal because now it is a
String constant expression. Result is known at compile time because it is based on final variables. Hope this will help u. feel free to correct me any time.
Regards
Vivek
PS: jim I am using your example to explain the things with little change. Please correct me if I am wrong. [This message has been edited by Vivek Shrivastava (edited July 18, 2000).]