title: How can I avoid SuppressWarnings("unchecked") in this generic method?
body: <p>How can I get rid of @SuppressWarnings("unchecked") in this method?</p>
  
  <pre><code>@SuppressWarnings("unchecked")
  public &lt;T&gt; Worker&lt;T&gt; findSimilarWorker(Worker&lt;T&gt; worker) {
      // The variable workers is a Set&lt;Worker&lt;?&gt;&gt;
      for(Worker&lt;?&gt; w : workers) {
          // The following line is unchecked cast
          if(w.isSimilar(worker)) return (Worker&lt;T&gt;) w;
      }
  
      return null;
  }
  </code></pre>