What is the difference and equals in Java

0 votes
Is there any difference between == and equals() in Java? How to compare enum?
Jun 5, 2018 in Java by Daisy
• 8,140 points
982 views

1 answer to this question.

0 votes

Both the answers (Syntaxes) are correct. If you look at the source code for .equals(), it simply defers to ==.

I use ==, because it is null safe.

Hope this helps!

Check out Java online course to learn more about it.

Thanks!

answered Jun 5, 2018 by Akrati
• 3,190 points

Related Questions In Java

0 votes
2 answers

What is the difference between getAttribute() and getParameter() in java?

getParameter() returns http request parameters. Those passed from ...READ MORE

answered Aug 28, 2019 in Java by Sirajul
• 59,230 points
22,551 views
0 votes
2 answers

What is the difference between Type List and type ArrayList in Java

By List, you actually tell, that your object ...READ MORE

answered Aug 28, 2019 in Java by Sirajul
• 59,230 points
2,567 views
0 votes
1 answer

What is the difference between getPath(), getAbsolutePath() and getCanonicalPath() in Java?

getPath() - returns a String which denotes the ...READ MORE

answered Jul 26, 2018 in Java by Mrunal
• 680 points
1,909 views
0 votes
1 answer

What is the need to override the equals and hashCode methods in Java?

You must override hashCode() in every class ...READ MORE

answered Jan 2, 2019 in Java by Daisy
• 8,140 points
3,337 views
+1 vote
1 answer

Are arrays equivalent to objects in Java ?

Yes; the Java Language Specification writes: In the Java ...READ MORE

answered May 10, 2018 in Java by Rishabh
• 3,620 points
1,326 views
0 votes
2 answers

Java enum lookup using a String

Check this...Java Enum in details READ MORE

answered Dec 4, 2018 in Java by allenvarna
• 540 points
956 views
+1 vote
1 answer

Remove objects from an array in Java?

We can use external libraries: org.apache.commons.lang.ArrayUtils.remove(java.lang.Object[] array, int ...READ MORE

answered Jun 26, 2018 in Java by scarlett
• 1,290 points
1,185 views
+1 vote
1 answer

Performance difference of if/else vs switch statement in Java

The thing you are worried about is ...READ MORE

answered Jul 26, 2018 in Java by geek.erkami
• 2,680 points
3,739 views
0 votes
2 answers

What is the difference between Set and List in java?

List is an ordered sequence of elements. ...READ MORE

answered Apr 26, 2018 in Java by Akrati
• 3,190 points
63,360 views
0 votes
1 answer

What is the difference between jdk and jre?

JRE: It stands for Java Runtime Environment. ...READ MORE

answered Apr 20, 2018 in Java by Akrati
• 3,190 points
1,957 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP