title: Java: Instanceof and Generics
body: <p>Before I look through my generic data structure for a value's index, I'd like to see if it is even an instance of the type <code>this</code> has been parametrized to.</p>
  
  <p>But Eclipse complains when I do this:</p>
  
  <pre><code>@Override
  public int indexOf(Object arg0) {
      if (!(arg0 instanceof E)) {
          return -1;
      }
  </code></pre>
  
  <p>This is the error message:</p>
  
  <blockquote>
    <p>Cannot perform instanceof check against type parameter E. Use instead its erasure Object since generic type information will be erased at runtime</p>
  </blockquote>
  
  <p>What is the better way to do it?</p>