Please see the code below.
"Double"(upper D) is used in HashSet, and "double" is used for x1, x2 and x3. After x1 is added to the HashSet, x2 cannot be added, but x3 can! Why??????
Thanks in advance :)
HashSet<Double> hs = new HashSet<Double>();
double x1, x2, x3;
x1 = (double)0/1;
System.out.println(hs.add(x1)); //true
x2 = (double)0/2;
System.out.println(hs.add(x2)); //false
x3 = (double)0/-1;
System.out.println(hs.add(x3)); //true
And if you add "0.0 +" for x1, x2 and x3, the result is as follows.
x1 = 0.0 + (double)0/1;
System.out.println(hs.add(x1)); //true
x2 = 0.0 + (double)0/2;
System.out.println(hs.add(x2)); //false
x3 = 0.0 + (double)0/-1;
System.out.println(hs.add(x3)); //false