javaamortization

Loan Amortization returns only the last item java


I am stuck with a Loan Amortization List which gives me only the last item multiple times. My method:

 public List<AmortizationScheduleLineItem> calculateAmortizationSchedule() {
        List<AmortizationScheduleLineItem> lineItems = new ArrayList<AmortizationScheduleLineItem>();

        AmortizationScheduleLineItem item = new AmortizationScheduleLineItem();

        long balance = amountBorrowed;
        int paymentNumber = 0;
        long totalPayments = 0;
        long totalInterestPaid = 0;

        item.setPaymentNumber(paymentNumber++);
        item.setPaymentAmount(0d);
        item.setPaymentInterest(0d);
        item.setCurrentBalance(((double) amountBorrowed) / 100d);
        item.setTotalPayments(((double) totalPayments) / 100d);
        item.setTotalInterestPaid(((double) totalInterestPaid) / 100d);
        lineItems.add(item);
        final int maxNumberOfPayments = initialTermMonths + 1;
        while ((balance > 0) && (paymentNumber <= maxNumberOfPayments)) {
            long curMonthlyInterest = Math.round(((double) balance) * monthlyInterest);
            long curPayoffAmount = balance + curMonthlyInterest;
            long curMonthlyPaymentAmount = Math.min(monthlyPaymentAmount, curPayoffAmount);
            if ((paymentNumber == maxNumberOfPayments)
                    && ((curMonthlyPaymentAmount == 0) || (curMonthlyPaymentAmount == curMonthlyInterest))) {
                curMonthlyPaymentAmount = curPayoffAmount;
            }

            long curMonthlyPrincipalPaid = curMonthlyPaymentAmount - curMonthlyInterest;

            long curBalance = balance - curMonthlyPrincipalPaid;

            totalPayments += curMonthlyPaymentAmount;
            totalInterestPaid += curMonthlyInterest;

            item.setPaymentNumber(paymentNumber++);
            item.setPaymentAmount(((double) curMonthlyPaymentAmount) / 100d);
            item.setPaymentInterest(((double) curMonthlyInterest) / 100d);
            item.setCurrentBalance(((double) curBalance) / 100d);
            item.setTotalPayments(((double) totalPayments) / 100d);
            item.setTotalInterestPaid(((double) totalInterestPaid) / 100d);
            lineItems.add(item);
            // Set P equal to Q and go back to Step 1: You thusly loop around until the value Q (and hence P) goes to zero.
            balance = curBalance;

        }

        return lineItems;
    }

My Web Service Method:

@WebResult(name = "PaymentPlan")
    @WebMethod(operationName = "GetLoanPaymentPlan")
    public List<AmortizationScheduleLineItem> GetLoanPaymentPlan() {
        AmortizationScheduleInput input = new AmortizationScheduleConsoleInputOutput().readUserInputFromConsole();
        LoanAmortizationSchedule loan = new LoanAmortizationSchedule(input);
        return loan.calculateAmortizationSchedule();
    }

My Response:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <ns2:GetLoanPaymentPlanResponse xmlns:ns2="http://service.dfcu.com/">
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
         <PaymentPlan>
            <currentBalance>0.0</currentBalance>
            <paymentAmount>0.05</paymentAmount>
            <paymentInterest>0.0</paymentInterest>
            <paymentNumber>61</paymentNumber>
            <totalInterestPaid>396095.05</totalInterestPaid>
            <totalPayments>1396095.05</totalPayments>
         </PaymentPlan>
      </ns2:GetLoanPaymentPlanResponse>
   </S:Body>
</S:Envelope>

What do I do to get the other items in the List?


Solution

  • You need to create a new item object in each iteration of your loop

    while (....) 
    {
      AmortizationScheduleLineItem item = new AmortizationScheduleLineItem();
      ...
      listItems.add (item);
    }
    

    otherwise you are working on the same object all the time