• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX:[URLyBird]What collection can be used?

 
Richard Jackson
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • 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
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • 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
     
    Mark Spritzler
    ranger
    Sheriff
    Posts: 17278
    6
    IntelliJ IDE Mac Spring
    • Mark post as helpful
    • send pies
    • 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
     
    Philippe Maquet
    Bartender
    Posts: 1872
    • Mark post as helpful
    • send pies
    • 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 ]
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic