[NTLUG:Discuss] Java/Linux versus school teacher.

steve sjbaker1 at airmail.net
Mon Mar 19 13:12:56 CDT 2007


Patrick R. Michaud wrote:

> It's okay for the compiler to make both references point to the
> same string [1].  Also, from "Core Java Technologies Technical 
> Tips" [2]:
> 
>     The Java platform creates an internal pool for string 
>     literals and constants. String literals and constants that 
>     have the exact same char values and length will exist exactly 
>     once in the pool. Comparisons of String literals and constants 
>     with the same char values will always be equal.
> 
> So, this would seem to indicate that for the way the question
> was phrased, one should always get the value "(a) true" 
> (which is the way I remember it being).  :-) :-)
> 
> [1]  http://wsjoung.wordpress.com/2006/11/26/string-constant-pool/
> [2]  http://java.sun.com/mailers/techtips/corejava/2006/tt0822.html

Aha!  Perfect!  Chapter and verse!

So my kid gets an extra point on his test result (although, morally,
he doesn't deserve it because he got it right for the wrong reason).



More information about the Discuss mailing list