Originally posted by Kamal Arora:
The "==" operator simply checks for the reference equality. i.e it simply compares whether the reference variables point to the same objects in the memory or not. Whereas .equals() is meant to actually compare the object values rather than comparing their references.
Originally posted by shweta pande:
Thanks for the reply but still there is a query.
In 1st and 2nd example,every thing is same so why it is giving "False"answer?
shweta
Originally posted by shweta pande:
[QB]Thanks Henry
== operater is used for ref. variables and equals() method is used for objects.Right?
But in the given example == is used for objects rather than ref. variables.
QB]
== operater is used for ref. variables and equals() method is used for objects.Right?
Originally posted by shweta pande:
can you please give me the example where two ref.variables are compared with == operater and giving true value.
shweta
Double a = new Double(10.0);
Double b = a;
Originally posted by shweta pande:
can you please give me the example where two ref.variables are compared with == operater and giving true value.
In order to save some memory, two instances of the following wrapper classes will be equal when there primitive values are same.
Boolean
Byte
Short and Integer(-128 to 127)
Character (/u0000 to /u007f)
Consider Paul's rocket mass heater. |