title: Java Generics: Multiple Bounds
body: <p>I have this code:</p>
  
  <pre><code>public class Test {
  
      public static void main(String[] args) {
          Test t = new Test();
          t.callTest();
      }
  
      public void callTest() {
          GenericTest gt = new GenericTest&lt;Date&gt;(); // this line don't compile
          gt.test(new Date());
      }
  
      class GenericTest&lt;T extends Date &amp; List&gt; {
          T x;
  
          public void test(T y) {
              System.out.println(x.toString());
          }
      }
  }
  </code></pre>
  
  <p>I understand why <code>new GenericTest&lt;Date&gt;()</code> doesn't compile, it is because Date doesn't implement List interface, but if I instantiate <code>GenericTest gt = new GenericTest()</code> without generic, the whole code works, and I don't understand why. The method test expects <code>(T y)</code> where <code>T extends Date</code> and implements <code>List</code>, but it works with <code>gt.test(new Date())</code>.</p>