• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

NX:[URLyBird]What collection can be used?

 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,every one
When I want to store records into some kind of collection,I dont sure the one which I can select.
Considering advantages or disadvantages,I need help to decide select Vector , ArrayList or other collections.
Would you like to comment on?
Regards,
Richard
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Richard
Perhaps you shold make a list of what your requirements for this collection are.
Some ideas to start you off:
  • Do you care about the order the items in the collection are stored in?
  • Do you care about duplicates in the collection?
  • Is your collection only going to store the one item (the record) or are you going to store some key/value combination?
  • Do you need implicit thread safety, or is your code accessing the collection going to be thread safe?


  • As you start progressing through your list of requirements, you will find that they will lead you to one particular class to use.
    Regards, Andrew
     
    ranger
    Posts: 17347
    11
    Mac IntelliJ IDE Spring
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Just one simple comment to add to Andrew's response. Vector and HashTable are considered older collections and Sun would rather you use the ArrayList and HashMap instead. Vectors and HashTables are automatically synchornized for you, which makes them a little slower.
    Mark
     
    Bartender
    Posts: 1872
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Richard,


    When I want to store records into some kind of collection,I dont sure the one which I can select.
    Considering advantages or disadvantages,I need help to decide select Vector , ArrayList or other collections.
    Would you like to comment on?



    I d' like to comment your question. Sometimes, reading them, I just wonder if you are SCJP, which is a prerequisite before going on with the SCJD assignment.
    Anyway, as recognizing the right collection to be used in a particular context is a SCJP-exam objective, you should be able to do it by yourself, IMO.
    Regards,
    Phil.
    [ September 29, 2003: Message edited by: Andrew Monkhouse ]
     
    You showed up just in time for the waffles! And this tiny ad:
    Gift giving made easy with the permaculture playing cards
    https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
    reply
      Bookmark Topic Watch Topic
    • New Topic