== (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]
# 1

> 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].

TimTheEnchantora at 2007-7-14 18:51:57 > top of Java-index,Java Essentials,New To Java...
# 2
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 > top of Java-index,Java Essentials,New To Java...
# 3
> 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~
yawmarka at 2007-7-14 18:51:57 > top of Java-index,Java Essentials,New To Java...
# 4

> 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."

BinaryDigita at 2007-7-14 18:51:58 > top of Java-index,Java Essentials,New To Java...
# 5
Thanks all of you for your replies
jaaya at 2007-7-14 18:51:58 > top of Java-index,Java Essentials,New To Java...
# 6
> For equals method I can have a look at the API.And for operators, you can have a look at the language specifications.
TimTheEnchantora at 2007-7-14 18:51:58 > top of Java-index,Java Essentials,New To Java...
# 7
> > 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 > top of Java-index,Java Essentials,New To Java...
# 8
> ...or any textbookMy corporate financial reporting textbook has nothing of the sort.~
yawmarka at 2007-7-14 18:51:58 > top of Java-index,Java Essentials,New To Java...
# 9
> My corporate financial reporting textbook has nothing> of the sort.You overlooked it. Page 314, second paragraph.
CeciNEstPasUnProgrammeura at 2007-7-14 18:51:58 > top of Java-index,Java Essentials,New To Java...
# 10
> > ...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 > top of Java-index,Java Essentials,New To Java...
# 11
> 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)~
yawmarka at 2007-7-14 18:51:58 > top of Java-index,Java Essentials,New To Java...
# 12
> You overlooked it. Page 314, second paragraph.Straight-line depreciation. No '==' symbols to be found. How disappointing!~
yawmarka at 2007-7-14 18:51:58 > top of Java-index,Java Essentials,New To Java...
# 13

> > 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 > top of Java-index,Java Essentials,New To Java...
# 14
> I actually knew that someone would nitpick on it when I posted :)I wouldn't want to let you down. ;o)~
yawmarka at 2007-7-14 18:51:58 > top of Java-index,Java Essentials,New To Java...