aspose file tools
The moose likes Beginning Java and the fly likes loading objects into arraylist Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "loading objects into arraylist" Watch "loading objects into arraylist" New topic
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
    
  11

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
    
  13

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
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: loading objects into arraylist
 
Similar Threads
Naming Objects
creating and binding components at runtime in Swing
Would a HashSet be a way to solve this problem?
Legacy generic and generic.
Comparator