title: "double, Double, HashSet" in Java
body: <p>Please see the code below. </p>
  
  <p>"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??????</p>
  
  <p>Thanks in advance :)</p>
  
  <pre><code>HashSet&lt;Double&gt; hs = new HashSet&lt;Double&gt;();
  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
  </code></pre>
  
  <hr>
  
  <p>And if you add "0.0 +" for x1, x2 and x3, the result is as follows.</p>
  
  <pre><code>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
  </code></pre>