swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Differences between JDK and Kaffe (Was: Swarm, Kaffe and AWT)


From: Marie-Edith Bissey
Subject: Re: Differences between JDK and Kaffe (Was: Swarm, Kaffe and AWT)
Date: Fri, 28 Sep 2001 11:01:21 +0200 (MEST)

On Thu, 27 Sep 2001, Tom Wainwright wrote:

|Marie-Edith Bissey wrote:
|>
|> 2) With Kaffe, I could compare a String variable with a string using
|> the == operator:
|>
|> String variable="first";
|> variable=="first"; // return true
|>
|> With JDK, the same bit of code returns false. Is there another way
|> than == to compare strings?
|>
|This is an area of Java where there seems to be some disagreement on
|implementation.  By definition, the "==" operator on objects determines
|if the right and left hand sides of the expression refer to exactly the
|same object; it is not a comparison of identity of object contents.  In
|this case, you have created two seemingly identical strings, but they
|may be stored in different objects (apparently depending on the compiler
|you use), with the result that "first" != "first".  So, the "==" test on
|strings is not reliable.  To test equality of the contents of objects
|(rather than their storage location) use the "equals()" method.

I understand. I also found within the String class the
compareTo(String) method, which deals with the comparison of one
string with another (or another object containing a String).

Marie-Edith.

__________________________________________________________________

Marie-Edith Bissey
Universita` del Piemonte Orientale "Amedeo Avogadro"
Facolta` di Science Politiche         email: address@hidden
Corso Borsalino 50                    tel: +39-0131-283700
15 100 Alessandria -- ITALIA          fax: +39-0131-263030
http://polis.unipmn.it/doc/bis/hp.htm


                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]