Hello all,
> I say syntactically because this is the strict translation of your code.
> A good compiler could optimize away this difference. The compilers have
> special handling of String object in a few places anyway.
Be careful here - the java language requires two identical string
constants to be equal:
String s1 = "hello";
String s2 = "hello";
System.out.println(s1 == s2); // returns 'true'
The language spec also requires new instances of a String to *not* be
equal to the constant:
String s1 = "hello";
String s2 = new String("hello");
System.out.println(s1 == s2); // returns 'false'
Because of these distinctions, a compiler is not allowed to optimize in
the fashion you suggest.
-Larry
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]