Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2012
    Posts
    3
    Rep Power
    0

    Default What is the use of Vector where as Arraylist can be Synchronized?

    Hi All,
    it may silly question but any how need to know more details.

    The difference between Vector and ArrayList is thread safe whereas Arraylist is not. but as the arraylist can be make synchronized what is the necessity of Vector?

    also
    Enumeration and Iterator?

    thanks in advance.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: What is the use of Vector where as Arraylist can be Synchronized?

    Vector is a legacy class from pre-1.2 (along with Hashtable).
    1.2 saw the introduction of the Collections framework.

    Same for Enumeration.
    Please do not ask for code as refusal often offends.

  3. #3
    Join Date
    Apr 2012
    Posts
    3
    Rep Power
    0

    Default Re: What is the use of Vector where as Arraylist can be Synchronized?

    Fine, one more question releated to this, how to check whether the current ArrayList object is synchronized or not?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: What is the use of Vector where as Arraylist can be Synchronized?

    That's easy.
    An ArrayList is not synchronised.
    You can get a List that is synchronised based on an ArrayList using Collections.synchronizedList(), but the ArrayList itself won't be synchronised.
    Please do not ask for code as refusal often offends.

Similar Threads

  1. Difference between Vector and Arraylist
    By Lil_Aziz1 in forum New To Java
    Replies: 10
    Last Post: 09-04-2012, 09:18 PM
  2. Synchronized ArrayList
    By java4amanda in forum New To Java
    Replies: 1
    Last Post: 05-08-2012, 11:56 AM
  3. Replies: 12
    Last Post: 07-07-2011, 08:49 PM
  4. Vector<vector> loop thru
    By ocean in forum New To Java
    Replies: 11
    Last Post: 11-21-2009, 02:17 PM
  5. Replies: 3
    Last Post: 11-07-2009, 05:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •