title: Use math operators on generic variables in a generic Java class
body: <p>I'm trying to write some code that will allow me to perform basic math operations on a "T extends Number" object instance. It needs to be able to handle any number type that is a subclass of <code>Number</code>.<br>
  I know some of the types under <code>Number</code> have <code>.add()</code> methods built in, and some even have <code>.multiply()</code> methods. I need to be able to multiply two generic variables of any possible type. I've searched and searched and haven't been able to come up with a clear answer of any kind.  </p>
  
  <pre><code>public class Circle&lt;T extends Number&gt; {
  
  private T center;
  private T radius;
  private T area;
  
  // constructor and other various mutator methods here....
  
  /**
    The getArea method returns a Circle
    object's area.
    @return The product of Pi time Radius squared.
  */
  public Number getArea() {
      return  3.14 * (circle.getRadius()) * (circle.getRadius());      
  }  
  </code></pre>
  
  <p>Any help would be much appreciated. Generics are the most difficult thing I've encountered in learning Java. I don't mind doing the leg work because I learn better that way, so even a strong point in the right direction would be very helpful. </p>