title: Generic method for number types
body: <p>Is there any way to make a generic method work with its type parameter as if it were a number? For example, consider a method that takes any number and returns its value doubled while keeping the input type. </p>
  
  <pre><code>static &lt;T&gt; T foo(T number)  {
      return number*2;
  }
  </code></pre>
  
  <p>This doesn't compile because <code>*</code> isn't defined for <code>T</code> and <code>int</code>. Changing <code>T</code> to <code>&lt;T extends Number&gt;</code> doesn't help, casting <code>(T)2</code> doesn't compile either.</p>