[NTLUG:Discuss] Java/Linux versus school teacher.
Patrick R. Michaud
pmichaud at pobox.com
Mon Mar 19 11:08:14 CDT 2007
On Mon, Mar 19, 2007 at 10:57:16AM -0500, Patrick R. Michaud wrote:
> So, the answer "(a) true" is equally as wrong as "(b) false",
> in that it's completely wrong to assume that x==y will
> give a repeatable answer based on the values of x and y
> (because x==y doesn't check for value equality).
Sorry, I wrote this backwards -- I meant to say that
"(b) false" (the teacher's answer) is equally as wrong
as "(a) true" (the student's answer).
It's wrong because x == y tests the identity of x and y,
and in the case of Strings the compiler is permitted
to cause equal-valued results to refer to a shared String
object.
Pm
More information about the Discuss
mailing list