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

Опубликовано: 03 Сентябрь 2012
на канале: 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)


На этой странице сайта вы можете посмотреть видео онлайн best java interview question what is the difference between == and equals method длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Interview DOT 03 Сентябрь 2012, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 1,856 раз и оно понравилось 7 зрителям. Приятного просмотра!