problem with for loop
<p>I have problem with 2 for loop</p>

<p>my code :</p>

<pre><code>public void updateCart(){


         int i = 0 ;
         int oldQoH = 0;
         // first loop get/set old value of quantity
        for(Cart CartOldQoH : getUserCart()){

            for(Cart cartQuantityOnHand : cartList){


            i = cartQuantityOnHand.getCartQuantity();
            // second loop get new value of Quantity

                int instock = CartOldQoH.getItem().getInstock();
                oldQoH = CartOldQoH.getCartQuantity();
                QoHInstock =  instock + oldQoH  ;
                //itemDAO.updateItemsFromCart(cartQuantityOnHand.getItem().getItemid().intValue(), QoHInstock);

               // System.out.println(QoHInstock);
                 System.out.println(i + " " + QoHInstock);


            }


        }

     }
</code></pre>

<p>i want calculate item instock is instock + old Quantity - new Quantity = current instock
it means if i have instock is 10 and old quantity is 3 total is 13 but it is total of item, after that i substract new Value of Quantity user edit from his cart and result is item remain instock.</p>

<p>My Prolem is 2 loop are not loop equal i don't know how do it work equals
i can exaplain here:
result of 2 loop will display sample:</p>

<pre><code>new value ------------------   old Value

3   ----------------------------- 2

4   ------------------------------2

5   ------------------------------2

6   ------------------------------2

=======================================


3   ----------------------------- 1

4   ------------------------------1

5   ------------------------------1

6   ------------------------------1

=======================================


3   ----------------------------- 5

4   ------------------------------5

5   ------------------------------5

6   ------------------------------5


=======================================



3   ----------------------------- 4

4   ------------------------------4

5   ------------------------------4

6   ------------------------------4
</code></pre>

<p>As you can see i have 4 items in cart and update list of 4 items. code above i unexpect display, i want it will display such as:</p>

<pre><code>3   ----------------------------- 2

4   ------------------------------1

5   ------------------------------5

6   ------------------------------4
</code></pre>
