This simple Java code adds 2 to a set of long, and subsequently prints whether 2 is a member of the set:

import java.util.*;

class A {
    public static void main(String[] args) {
        HashSet<Long> s = new HashSet<Long>();
        long x = 2;
        s.add(x);
        System.out.println(s.contains(2));
    }
}

It should print true since 2 is in the set, but instead it prints false. Why?

$ javac A.java && java A
false
Edit
Report