• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dynamic Arrays In Java

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
My cellmate was this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic