Skip to content

Instantly share code, notes, and snippets.

@DanyelMorales
Last active January 25, 2017 04:12
Show Gist options
  • Save DanyelMorales/66d3956a35504d424babdc78df17c9eb to your computer and use it in GitHub Desktop.
Save DanyelMorales/66d3956a35504d424babdc78df17c9eb to your computer and use it in GitHub Desktop.
Equality in java

"==" Compares the bits in two variables. Check if two variables are the same. Zeros on the left end don't matter.

int a = 2; byte b = 3; (a == b); // true

.equals() Check the equality of two objects that are different in the heap but they are the same type. It depends on what makes sense for that particular type.

String x = "a"; String y = "a";

(x.equals(y)); // true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment