how to combine object item and sum up qty - JAVA
<p>i having an object with below information</p>

<p>TransHdr: id, order_num</p>

<p>TransItem: hdr_id, product_code, refnum, qty (child record)</p>

<p>transHdr.id=transItem.hdr_id</p>

<p>if let say 3 record can be found in TransItem, </p>

<p>parkA,112,10</p>

<p>parkA,112,6</p>

<p>parkB,113,10</p>

<p>i would like group it base on refnum, means that my result will be</p>

<p>parkA,112,<strong>16</strong></p>

<p>parkB,113,10</p>

<p>i need a method that will loop the object (item level) and need to return transHdr object to other function. anyway to do this?</p>

<pre><code>for (java.util.Iterator&lt;ITransItem&gt; groupTransItems = TransHdr.getTransItems().iterator(); 
        groupTransItems.hasNext();) {
        ITransItem _TransItem = groupTransItems.next();
        if (null!=_TransItem.getRefNum()){
        &lt;question here..how do i group and sum up my item and become only 1 record?&gt;
        }

    }
    return newGroupingTransHdr;
}
</code></pre>
