When you use a Map, there is no defined order in which the entries will be
enumerated. The actual order is implementation-specific. If you need a
particular order, then it is up to you to take care of that.
--
Martin Cooper
----- Original Message -----
From: "Ali Ozoren" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, September 23, 2001 7:34 PM
Subject: RE: Postmortem (iterate, wrap, hashtable, nested)
> richard- i appreciate the input. i'd expect it to give back in the natural
> order, the order in which i put my items. however, something else is going
> on apparently. --a
>
> -----Original Message-----
> From: Richard Yee [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, September 23, 2001 3:47 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Postmortem (iterate, wrap, hashtable, nested)
>
>
> Ali,
> You are getting the InvoiceLineItems out of order b/c you are storing them
> in a Map or Hashtable. These collections do not preserve the order of the
> objects as they are inserted into them. If you want to preserve the
> ordering, you need to use a Collection that implements the List interface
> (ArrayList, LinkedList) You could use a TreeMap or SortedMap, but these
> would incur more overhead for your application than using a collection
that
> implements the List interface.
>
> -Richard
>
>