Difference between '== operator' and 'equals() method' in java?

preview_player
Показать описание
DURGASOFT is INDIA's No.1 Software Training Center offers
online training on various technologies like JAVA, .NET ,
ANDROID,HADOOP,TESTING TOOLS , ADF, INFORMATICA, SAP...
courses from Hyderabad & Bangalore -India with Real Time Experts.
so that our Supporting Team will arrange Demo Sessions.
Ph:Call +91-8885252627,+91-7207212428,+91-7207212427,+91-8096969696.
Рекомендации по теме
Комментарии
Автор

I think I only understood every 10th word but it was still a better explanation than most!

explodingpizza
Автор

Great explanation. But the accent is a big struggle for non-indians.

okeyxyz
Автор

your explanation is great. Thank you! Big like for you, sir

DaiLyUyQuyenEPS
Автор

awesome teaching and thankyou so much for these helpful videos, really appreciate your effort!

persistencej
Автор

My question is if interviewer asks the difference between == and .equals()
how can it be specific to String scenario. In StringBuffer .equals() don't act as content comparison because it doesn't override the parent Object class where as in String .equals() overrides parent Object class. So, that means equals() in root/Object class isn't meant for content comparison but for reference comparison, but String overrides it for it's own class implementation. Why are we saying equals() do content comparison? It does content comparison only for String datatypes and for the rest it does ref. comparison!!

richcohen
Автор

Super sir.. it's clearly explained...

sundar.m
Автор

I wish i only had watched this video before my lately bad job interview

pouriaka
Автор

Both are true in this example. Please apply string literal pool concept.

sidharthavelaga
Автор

Hello sir,
Thankyou for th very nice explanation just one doubt.
At last you said in String and Collection equals() method compares content so what happens with the other class like Integer where 9 == 9 also returns true and two different Integer object with 9 and 9 also returns true.

Raviranjankumar
Автор

explain the last note part in details please

raaghavsharma
Автор

int a=5;
int b=5;
a== b is giving true, here its checking content or reference.... 
String a="xxx";
String b="xxx";
a==b is giving true only, when string is created through object that time only false....why this....???

sivamuthu
Автор

Why c programming == not check reference only content check...

maulikdhaduk
Автор

public static void main(String[] args) {
String s1 = "Durga";
String s2 = "Durga" + "Software";
String s3 = s1 + "Software";
System.out.println(s2 == s3);
}

The above code will print false, But if i will make s1 as a final then it will print true. Can someone explain what is the reason behind the scene. :)

kuldeepchoudharykp
Автор

indian guyz are still the best in software whatsover from whenever

yichaoyao
Автор

Sir can you give me advance video link... plz sir

RAJANIKANTA
Автор

public boolean equals(Object obj)
  {
    if (this == obj) return true;
    if (obj == null) return false;
    if (this.getClass() != obj.getClass()) return false;
    Person that = (Person) obj;
    if (this.age != that.age) return false;
    if return false;
    if return false;
return true;
  }I have a piece of code like above, in that code why we are checking for the inequality of classes [ if (this.getClass() != obj.getClass()) return false;]I mean why should we  check for the inequality of classes instead of checking for the equality of classes.and why do we need to check all  those things, could u please explain me a little bit In detail.Thanks in advance.

ganeshdikonda
Автор

Wt abt this String s="durga";
String s1=new String ("durga");
s==s1

santhoshPatels
Автор

String str1 = new String("java");
String str2 = new String(str1);

S.o.pln(str1==str2)
Still false as str2 points towards str1???please help here

S.o.pln(str1.equals(str2)); true

friendlychannel
visit shbcf.ru