== (execution)
Say a and b are Strings.so if we write a.equals(b) it means that equals method of java.lang.String is called.But which method is called if we use a==b
[185 byte] By [
jaaya] at [2007-10-3 1:53:29]

> Say a and b are Strings.
> so if we write a.equals(b)
it means
> that equals method of java.lang.String is
> called.
>
> But which method is called if we use a==b
Not a method, a [url=http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.21.3](reference) equality operator[/url].
ok, so how do I know what happens in the background.For equals method I can have a look at the API.Is there any way that background implementation by JVM for == can be known?
jaaya at 2007-7-14 18:51:57 >

> Is there any way that background implementation by> JVM for == can be known?Check the VM spec for if<cond>, if_icmp, if_acmp, etc. instructions. http://java.sun.com/docs/books/vmspec/2nd-edition/html/Instructions2.doc6.html#if_acmpcond~
> ok, so how do I know what happens in the background.
> For equals method I can have a look at the API.
> Is there any way that background implementation by
> JVM for == can be known?
From the link he gave you:
"At run time, the result of == is true if the operand values are both null or both refer to the same object or array; otherwise, the result is false."
Thanks all of you for your replies
jaaya at 2007-7-14 18:51:58 >

> For equals method I can have a look at the API.And for operators, you can have a look at the language specifications.
> > For equals method I can have a look at the API.> > And for operators, you can have a look at the> language specifications....or any textbook
kajbja at 2007-7-14 18:51:58 >

> ...or any textbookMy corporate financial reporting textbook has nothing of the sort.~
> My corporate financial reporting textbook has nothing> of the sort.You overlooked it. Page 314, second paragraph.
> > ...or any textbook> > My corporate financial reporting textbook has nothing> of the sort.> > ~That's probably because it isn't found in the same section as the books about Java programming :)
kajbja at 2007-7-14 18:51:58 >

> That's probably because it isn't found in the same> section as the books about Java programming :)But... but... you said "any textbook"! My nitpickiness knows no bounds!;o)~
> You overlooked it. Page 314, second paragraph.Straight-line depreciation. No '==' symbols to be found. How disappointing!~
> > That's probably because it isn't found in the
> same
> > section as the books about Java programming :)
>
> But... but... you said "any textbook"! My
> nitpickiness knows no bounds!
>
> ;o)
>
> ~
I actually knew that someone would nitpick on it when I posted :)
kajbja at 2007-7-14 18:51:58 >

> I actually knew that someone would nitpick on it when I posted :)I wouldn't want to let you down. ;o)~