Bear Bibeault wrote:We are not your compiler. What happened when you tried it?
Rahul.p Kumar wrote:Begri, as you have been told, you will know the answer by running that piece of code yourself. Regarding why, think in terms of object and literals of strings and keep in mind overriding concept of equals() method.
s begri wrote:
for this if(s1.equals(s3)) it is also giving true , why ?
regards,
S
Priety.
Patricia Samuel wrote:
In short == is for comparing the references and equals is for comparing the values.
s begri wrote:Thanks every body for your reply,
I am confusing why if(s1.equals(s2)) is giving true
and why if(s1.equals(s3)) is giving true.
regards,
S
Bear Bibeault wrote:We are not your compiler. What happened when you tried it?
s begri wrote:
I am confusing why if(s1.equals(s2)) is giving true
and why if(s1.equals(s3)) is giving true.
See where your hand is? Not there. It's next to this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|