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

Publicado el: 03 septiembre 2012
en el canal de: 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)


En esta página del sitio puede ver el video en línea best java interview question what is the difference between == and equals method de Duración hora minuto segunda en buena calidad , que subió el usuario Interview DOT 03 septiembre 2012, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 1,856 veces y le gustó 7 a los espectadores. Disfruta viendo!