title: how to compare type of an object's instance to a generic type?
body: <p>how can i write this code in java?</p>
  
  <pre><code>public class ComponentsManager 
      {
          private List&lt;IComponent&gt; list = new ArrayList&lt;IComponent&gt;();
  
          public &lt;U extends IComponent&gt; U GetComponent() {
  
              for (IComponent component : list) {
  
                  if(component instanceof U)
                  {
                      return component;
                  }
              }
          }
  }
  </code></pre>
  
  <p>but i cant perform instanceof on generic types. how should i do it?
  thanks.</p>