Results 1 to 6 of 6

Thread: An ArrayList and a Vector

  1. #1
    Junior Member
    Join Date
    May 2006
    Answers
    12

    An ArrayList and a Vector

    Its me again
    I need to know the differences between an ArrayList and a Vector.
    Whoever knows, plz provide the answer

    FG


  2. #2
    Contributing Member
    Join Date
    May 2006
    Answers
    82

    Re: An ArrayList and a Vector

    Whether to use whether array list or vector depends on the situation ad factors. Sometimes Vector is better; sometimes ArrayList is better. But some of the following factors can be considered for usage decision like API, Synchronization, Data growth,usage patterns


  3. #3
    Contributing Member
    Join Date
    May 2006
    Answers
    71

    Re: An ArrayList and a Vector

    Some of the differences between an ArrayList and a Vector are Arraylist has no default size while vector has a default size, Arraylist don't define any increment size while vector does. But there is lot more which I am not aware. Hope somebody would throw highlight on this discussion.


  4. #4
    Junior Member
    Join Date
    May 2006
    Answers
    12

    Re: An ArrayList and a Vector

    Thanks timmy and fred
    Going by reply, It is evident a Vector is more efficient than an Arraylist.
    Bottomline is we need to choose either a Vector or an Arraylist based on the merits of the scenario - Right?


  5. #5
    Contributing Member
    Join Date
    May 2006
    Answers
    85

    Re: An ArrayList and a Vector

    Based of the usage the choice of arraylist or vector differs. I have added some more points to which can be considered while making choice between vector list and array. They are namely Vectors are synchronized. Any method that touches the Vector's contents is threading safe. Array List, on the other hand, is unsynchronized, making them, therefore, not thread safe. So if you don't need a thread-safe collection, use the Array List. If you don't know how much data you'll have, but you do know the rate at which it grows, Vector does possess a slight advantage since you can set the increment value.


  6. #6
    Junior Member
    Join Date
    Mar 2009
    Answers
    1

    Re: An ArrayList and a Vector

    how ever its always good to go for ArrayList, if you are using java1.5 in sense of performance.If you want to make it as threadsafe, u can do that at any time using

    collections.synchronizedList(arrayList) ;

    or we have some more methods in java.util.concurrent package,which we can use.


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