On Thu, 22 Apr 2004 15:20:52 +0800, "news.amnet.net.au"
<> wrote or quoted :
>...it looks like the values come out alphabetically in regards to the keys,
>rather than first key in -> first key out.
>
>Is there any other way I can store ArrayLists mapped to keys but where I can
>get first key in -> first key out?
1. You can have several collections indexing the same set of objects.
..e.g. you can look up by index number with an ArrayList AND lookup by
exact key with a HashMap AND lookup in sorted order by TreeMap.
2. If you want things sorted, the easiest way is to extract as
ArrayList and sort every time you need the list. see
http://mindprod.com/jgloss/sort.html. The alternative is to use a
TreeMap that keeps things sorted. Try both ways to understand when
each works better.
3. See
http://mindprod.com/products.html#SORTEDARRAYLIST
4. ArrayList is the easiest to lookup in entry order. If you wanted
to be silly you could generate keys by adding one each time to create
Integer objects and using a HashMap or TreeMap lookup. Don't do it,
unless you are just experimenting.
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See
http://mindprod.com/jgloss/jgloss.html for The Java Glossary.