title: Generics and instanceof - java
body: <p>OK this is my class, it encapsulates an object, and delegates equals and to String to this object, why I can´t use instance of???</p>
  
  <pre><code>public class Leaf&lt;L&gt;
  {
      private L object;
  
      /**
       * @return the object
       */
      public L getObject() {
          return object;
      }
  
      /**
       * @param object the object to set
       */
      public void setObject(L object) {
          this.object = object;
      }
  
      public boolean equals(Object other)
      {
          if(other instanceof Leaf&lt;L&gt;) //---&gt;ERROR ON THIS LINE
          {
              Leaf&lt;L&gt; o = (Leaf&lt;L&gt;) other;
              return this.getObject().equals(o.getObject());
          }
          return false;
      }
  
      public String toString()
      {
          return object.toString();
      }
  }
  </code></pre>
  
  <p>how can I get this to work??
  Thanks!</p>