title: How to use generics in calculate area method?
body: <p>I was trying to learn Generics in Java.</p>
  
  <p>I created a box class.</p>
  
  <p>package com.generic;</p>
  
  <pre><code>public class Box&lt;T&gt; {
  
      T length;   
      T breadth;
          // Setter and getter
  
  }
  </code></pre>
  
  <p>Now I wanted to create a method to caluclate area of the box which  will be <code>length * breadth</code>.</p>
  
  <p>I have made it generic so I can use Long , Double, Integer etc. </p>
  
  <p>But when i tried to create a method calculateArea like this</p>
  
  <pre><code>T area(T w , T h)
      {
          return (w * h); 
      }
  </code></pre>
  
  <p>But it is giving me compile time error.</p>
  
  <p>I think multiplication can't be performed on generics.</p>
  
  <p>So what i can do to make my <code>area</code> method generic?</p>
  
  <p>Thanks.</p>