Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

loading objects into arraylist

 
rames tirrupur
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64607
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to java in General (beginner).
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic