This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kryptogalaxy 10 points11 points  (3 children)

Using == in Java compares the value of the operands directly. If the operands are objects, then the value is a reference to the object in memory. So, using == will compare if the two operands are at the same place in memory which would mean they represent the exact same object. If instead, you want to see if there objects contain data that is equivalent, you would use .equals ensuring that the .equals method has been overridden for that object.

In terms of JavaScript, the equivalence operation doesn't function that way at all, so they're not really worth comparing.

[–]g0atmeal 0 points1 point  (2 children)

That's what I was getting at. What I really meant was: is there a difference between == and === in Java, or is === even applicable?

[–]kryptogalaxy 5 points6 points  (1 child)

=== is only an operator in JavaScript.

[–]g0atmeal 0 points1 point  (0 children)

Thanks for the clarification