title: java generics - method return type
body: <p>say i have a class Animal, and then classes Dog and Cat that extend it. Can i have a method then that returns dog or cat, depending on some value? so, something like this, except working :)</p>
  
  <pre><code>public &lt;T extends Animal&gt; getAnimal(){
    if (a)
      return new Dog();
    else
      return new Cat();
  }
  </code></pre>