Click here - / @interviewdot to get notifications. Welcome to http://www.InterviewDot.com
Java Interview Questions and Answers - In this tutorial you will see the difference between the == and equals for comparision in java.
For comparing equality of string ,We Use equals() Method.
There are two ways of comparison in java. One is "==" operator and another "equals()" method .
"==" compares the reference value of string object whereas equals() method is present in the java.lang.Object class.
This method compares content of the string object. .
Example :
String strsample 1= "AreYouLearning";
Strsample1 = address of "AreYouLearning" ie 24324 -- some address in memory
String strsample2 = "AreYouLearning";
Strsample2 = address of "AreYouLearning" ie 24324 -- some address in memory ,since string is IMMUTABLE
Strsample1 == strsample2 and strsample1.equals(strsample2)
On this page of the site you can watch the video online best java interview question what is the difference between == and equals method with a duration of hours minute second in good quality, which was uploaded by the user Interview DOT 03 September 2012, share the link with friends and acquaintances, this video has already been watched 1,856 times on youtube and it was liked by 7 viewers. Enjoy your viewing!