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

Publicado em: 03 Setembro 2012
no 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)


Nesta página do site você pode assistir ao vídeo on-line best java interview question what is the difference between == and equals method duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Interview DOT 03 Setembro 2012, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 1,856 vezes e gostou 7 espectadores. Boa visualização!