title: Java generics, method base() is undefined for the type T
body: <p>I am trying to understand generics in java, and trying this simple example, but can't make it work; it comes back with error </p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
            The method base() is undefined for the type T
            at javaTest.Main.testShape(Main.java:21)
            at javaTest.Main.main(Main.java:25)</p>
  </blockquote>
  
  <p>Below is the code</p>
  
  <pre><code>class Shape{
      int id=1;
      void base(){
          System.out.println("Shape.base()");
      }
  }
  
  // unrelated class, but same func name
  class OtherShape{
      float id=1.1f;
      void base(){
          System.out.println("OtherShape.base()");
      }
  }
  
  public class Main {
  
      static &lt;T&gt;void testShape(T shape){
          shape.base();
      }
  
      public static void main(String[] args) {        
          testShape(new Shape() );
          testShape(new OtherShape());        
      }
  }
  </code></pre>
  
  <p>any idea on how I can make it work ?</p>