title: java.lang.StackOverflowError adding set to set itself
body: <p>why below code is giving java.lang.StackOverflowError error</p>
  
  <pre><code>Set s = new HashSet();
  s.add(s);
  s.add(s);
  </code></pre>
  
  <p>What is the operation set performing internally and why it is calculating hash code every time?</p>
  
  <pre><code>Exception in thread "main" java.lang.StackOverflowError
      at java.util.HashMap$KeyIterator.&lt;init&gt;(HashMap.java:1459)
      at java.util.HashMap$KeySet.iterator(HashMap.java:916)
      at java.util.HashSet.iterator(HashSet.java:172)
      at java.util.AbstractSet.hashCode(AbstractSet.java:122)
      at java.util.AbstractSet.hashCode(AbstractSet.java:126)
      at java.util.AbstractSet.hashCode(AbstractSet.java:126)
      at java.util.AbstractSet.hashCode(AbstractSet.java:126)
      at java.util.AbstractSet.hashCode(AbstractSet.java:126)
  </code></pre>