aspose file tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX:[URLyBird]What collection can be used? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "NX:[URLyBird]What collection can be used?" Watch "NX:[URLyBird]What collection can be used?" New topic
Author

NX:[URLyBird]What collection can be used?

Richard Jackson
Ranch Hand

Joined: Jun 25, 2003
Posts: 128
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


Regards, Richard
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 10815
    
  25

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


    The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
    Mark Spritzler
    ranger
    Sheriff

    Joined: Feb 05, 2001
    Posts: 17225
        
        1

    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


    Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
    How to Ask Questions the Smart Way FAQ
    Philippe Maquet
    Bartender

    Joined: Jun 02, 2003
    Posts: 1872
    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 ]
     
    I agree. Here's the link: http://jrebel.com/download
     
    subject: NX:[URLyBird]What collection can be used?
     
    Similar Threads
    return type of multi-object finder/select
    Finalize and System.gc()
    Option collections problem
    Difference Between count() and size
    Hibernate lazy collections: What about the collection elements - are they lazy too?