Results 1 to 4 of 4

Thread: collections

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    collections

    what is the diff b/w vector and arraylist?
    which one is preferable to use?any new adv of the above?


  2. #2
    Junior Member
    Join Date
    May 2007
    Answers
    10

    Re: collections

    Quote Originally Posted by balumanickamM.tech View Post
    what is the diff b/w vector and arraylist?
    which one is preferable to use?any new adv of the above?
    1.Arraylist is not synchronized while vector is.
    2. Arraylist has no default size while vector has a default size of 10.
    3. Arraylist don't define any increment size while vector does.

    Methods in Vector are synchronised which means they are thread-safe and thus preclude access to the Vector elements by concurrent threads.But this imposes additional overhead on the JVM as it has to acquire and release locks on the vector objects under consideration.

    This is not possible in ArrayList since those methods are not synchronised and hence are faster in performance.

    Use Vector only if it will be accessed by multiple threads at a time else ArrayList is always better.


  3. #3
    Junior Member
    Join Date
    Dec 2006
    Answers
    9

    Re: collections

    which is Better?
    Depends on the requirement only we can able to choose the either Vector / ArrayList

    Differences :
    --------------
    1.Synchrnonization:
    -------------------
    Vector is Synchronised.ArrayList is Unsynchronised
    2.Data Growth:
    ----------------
    Both Vector and ArrayList are Dynamic arrays.
    Vector : doubling the size of its array
    ArrayList : 50% increase its array size
    3.Element Addition & Removal:
    -------------------------------
    Both Vector & ArrayList are good for adding & removing the element at the end.But if it comes to other positions boh are cost effective.So that time we have to search for better container like LinkedList.


  4. #4
    Junior Member
    Join Date
    May 2007
    Answers
    1

    Re:hi

    dear all,
    i am new member of this forum.

    thanks
    pulak


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact