What is the difference between == and equals()? - Cracking the Java Coding Interview

preview_player
Показать описание
Cracking the #Java #Coding #Interview - Question 9: What is the difference between == and equals()?
Рекомендации по теме
Комментарии
Автор

Because background music video voice is not audible

mustaqahmedshaikh
Автор

== Reference Comparision
equals() Compares Content/Actual value.

Dhan-pro
Автор

While comparing two strings references with == operator we may get false thought these two strings are equal because these two strings references are referring two different string objects.
== Operator returns true when these two references are referring to the same object, and return false when these two references are referring to two different object.
Please correct me if I am wrong.

chetankhandave
Автор

What about using == with enums? Considering every instance is known at compile time, and the compiler can comply if the "another" reference has a different type.

leandrotapia
Автор

For float and double, I thought you had to use Double.compare() and Float.compare() !

fioremarc
Автор

There is no difference. Did I mention I use Kotlin 😅

Syldar
Автор

== refrence comparison.equals() content comparison

mukhirais
Автор

What is the type and value of variable ‘a’ so that ‘a ==a’ is false?

PeterVerhas
Автор

could or should the compiler be able to change the == for float/double to the absolute value check?

JorgetePanete
Автор

For every question u drinks a one coffee

Dileepkumar-ywyn
Автор

Yeah you need a big brain to remember all of these inconsistencies in java.

linuxtutorialshindi
Автор

By the way
Integer.valueOf(127) == Integer.valueOf(127) // true
Integer.valueOf(128) == Integer.valueOf(128) // false

noredine