title: The correct way to return the only element from a set
body: <p>I have the following kind of situation:</p>
  
  <pre><code>Set&lt;Element&gt; set = getSetFromSomewhere();
  if (set.size() == 1) {
      // return the only element
  } else {
      throw new Exception("Something is not right..");
  }
  </code></pre>
  
  <p>Assuming I cannot change the return type of <code>getSetFromSomewhere()</code>, is there a better or more correct way to return the only element in the set than</p>
  
  <ul>
  <li>Iterating over the set and returning immediately</li>
  <li>Creating a list from the set and calling <code>.get(0)</code></li>
  </ul>