• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamic Arrays In Java  RSS feed

 
Brian Mulvany
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have a set of Java classes that parse a website looking for cd's. The amount of cd's vary depending on the search. I want to be able to sort the search results by price, album, artist etc. I figure one way to do this might be to use a dynamic array to store the results. I dont know how to do one of these or where to start. Has anybody here got any useful guidelines or hints as to where I can go and start.
Thanks
Brian
 
Horatio Westock
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you need dynamically sized collections of things, I recommend you read the Collections Trail. I'm sure you will find some interesting stuff there on storing and sorting collections of objects.
 
Yevgeniy Treyvus
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Brian,

I wrote a simple example for you that should get you started. But I think once you get into it, you will see that you will probably need to make improvements in order to make it useful in your application.



By the way here's the corresponding output:

Sorting by column 1 ...
[AbracadabraMagic Touch14.992003
, Matchbox 20Best Hits19.991999
, TitaniumsMetal Hits 10127.991967
]

Sorting by column 2 ...
[Matchbox 20Best Hits19.991999
, AbracadabraMagic Touch14.992003
, TitaniumsMetal Hits 10127.991967
]

Sorting by column 3 ...
[AbracadabraMagic Touch14.992003
, Matchbox 20Best Hits19.991999
, TitaniumsMetal Hits 10127.991967
]

Sorting by column 4 ...
[TitaniumsMetal Hits 10127.991967
, Matchbox 20Best Hits19.991999
, AbracadabraMagic Touch14.992003
]
[ April 01, 2005: Message edited by: Yevgeniy Treyvus ]
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!