best java interview question what is the difference between == and equals method

Publié le: 03 septembre 2012
sur la chaîne: Interview DOT
1,856
7

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)


Sur cette page du site, vous pouvez voir la vidéo en ligne best java interview question what is the difference between == and equals method durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Interview DOT 03 septembre 2012, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 1,856 fois et il a aimé 7 téléspectateurs. Bon visionnage!