equals() and hashCode()

Run Settings
LanguageJava
Language Version
Run Command
public class Main { public static void main(String[] args) { ABC a = new ABC(123); ABC b = a; ABC c = new ABC(123); System.out.println("==:"); System.out.println(a == b); System.out.println(a == c); System.out.println("\nequals():"); System.out.println(a.equals(b)); System.out.println(a.equals(c)); System.out.println("\nhashCode():"); System.out.println(a.hashCode()); System.out.println(b.hashCode()); System.out.println(c.hashCode()); } } class ABC { public int i; public ABC(int i) { this.i = i; } /* public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ABC abc = (ABC) o; return i == abc.i; } public int hashCode() { return i; } */ }
Editor Settings
Theme
Key bindings
Full width
Lines