How to sum the elements of an array list that stores objects : <p>I have a array list called Employees that stores Employee objects. Each employee has last name, first name, hour,pay pate, gross, tax, and net. I am trying to calculate the sum of each Employee's hour,pay pate, gross, tax, and net. Is there a way to extract specific element of an object from an array list?</p>

<p>I have tried to calculate the sum through user's input, however, it does not seem to work. </p>

<pre><code>//Employee class
public Employee getinfo(Employee info )
    {   
        info.LastName();
        info.FirstName();
        info.fullname();
        info.hours();//ask user to input hour
        toth += info.gethours();
        info.payrate();//ask user to input payrate
        totpr+= info.getpayrate();
        info.calcGross();
        totg+= info.getgross();
        info.calcTaxes();
        tott+= info.gettax();
        info.calcNet();
        totn+= info.getnet();
        return info;
    }

//Employees class
    Employee max=new Employee();

    public void add()
    {
        for (int i=0;i&lt;max.maxemps();i++)
        {
            Employee emp= new Employee();
            emp.getinfo(emp);
            list.add(emp);
        }
    }

</code></pre>

<pre><code>//Actual results
qwe, ewq            6.00     7.00    42.00     6.30     35.70
ttt, yyy            8.00     9.00    72.00     10.80    61.20
Total               0.00     0.00    0.00      0.00     0.00
Average             0.00     0.00    0.00      0.00     0.00

//Expecting
Total Total         14.00     16.00    114.00     17.1      96.9
Average             7.00      8.00     57.00      8.505     48.45
</code></pre>
