+ 1

== and .equals difference?

Sololearn told me to use == to test if something was equal to something. But a error happened so I asked chatgpt and it said I should use .equals? If(variable == (1)) is wrong! It was, if(variable.equals (1))

24th Jun 2025, 6:51 PM
Pou
1 Answer
+ 3
== checks the equality of a reference in memory; equals() checks the equality of values. provide the complete code and task instruction.
24th Jun 2025, 7:05 PM
Lisa
Lisa - avatar