can i use generic for float[] and int[]?
<p>we have two process classes which are almost identical except One is used to process a float[] data and another is for a int[] data.</p>

<p>I am thinking to combine them into one. My original thinking is use generic for float[] and int[].</p>

<p>Java generic is new to me. So I wrote the following test method to see how generic works but I cannot make it working for me.</p>

<pre><code>public &lt;T&gt; T caculate(T[] values)
    {
        T result;
        for(int i = 0; i &lt; values.length; i++)
        {
            result = result + values[i];
        }

        result = result/(values.length);
        return result;       
    }
</code></pre>

<p>Anybody can modify above method for me? float and int is primitive type in Java. Probably above method is not right.</p>
