Values & References3 / 16
Up next

== vs equals

class Main {
    public static void main(String[] args) {
        String a = new String("hi");
        String b = new String("hi");
        // == asks: the same object?
        System.out.println(a == b);
        // equals asks: the same contents?
        System.out.println(a.equals(b));
    }
}
What you're solving

identity versus value equality