Results 1 to 14 of 14

Thread: Iterator Problem

Threaded View

  1. #1

    Thread Starter
    Fanatic Member x-ice's Avatar
    Join Date
    Mar 2004
    Location
    UK
    Posts
    671

    Resolved Iterator Problem

    I am iterating through a collection of customer objects in an array list.
    Code:
    public void getCustomer() //TEST, DELETE AFTERWARDS
        {
            Iterator itCount = custDB.iterator();
            Customer thisCustomer = (Customer)itCount.next();
            //Loop tthrough all customers
            while(itCount.hasNext())
            {
                thisCustomer.print(); System.out.println(); //Blank line for presentation    
                //Move to next customer
                thisCustomer = (Customer)itCount.next();
            }
        }
    This code doesn't print the last object in the arraylist but it does print the first, and the rest. What could be the problem?
    Last edited by x-ice; Feb 25th, 2007 at 07:04 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width