| Author |
loading objects into arraylist
|
rames tirrupur
Greenhorn
Joined: Jul 25, 2006
Posts: 13
|
|
Hi All, I have a scenario where i need to add objects to arraylist based on some condition. eg: After firing sql, i get the results with duplicate customer number. I want to add the same customer numbers to one arraylist and add the different customer number to other arraylist. and finally add both the arraylist to hashmap. How to do this? Thanks, rames
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
This is basic java, not servlet related. Please post to the correct forum next time You know the HashMap class ? You use put() and get(), then you can solve your problem.
|
[My Blog]
All roads lead to JavaRanch
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56185
|
|
|
Moved to java in General (beginner).
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Richard Green
Ranch Hand
Joined: Aug 25, 2005
Posts: 536
|
|
what do you mean by "same" customer number and "different" cutsomer number? If by "same" you mean "unique" and by "different" you mean "duplicate" customer numbers., then the following code should achieve what you want. [ July 27, 2006: Message edited by: Lynette Dawson ]
|
MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
See if this answers the right question. This will make a map with key=customer number and value=a bunch of rows. Is that close?
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
 |
|
|
subject: loading objects into arraylist
|
|
|