JAVA Vector and ArrayList usage and performance comparison

Source: Internet
Author: User

 Same point:
    • All inherits from Abstractlist and implements the list interface
    • Both Randomaccess and cloneable interfaces are implemented.
    • The default array size is 10
    • All support iterator traversal

Different points:
    • ArrayList is non-thread safe;
and vector is thread-safe, its functions are synchronized, that is, all support synchronous
    • Serialization support differs:
ArrayList implements the Java.io.Serializable interface
    • Capacity increases in number of different:
when the capacity is low, theArrayListnew Capacity "=" (Raw capacity x3)/2 + 1 ""Vectornew capacity "=" raw capacity x 2 "
    • Index in different ways:
vector using V.indexof (o, index); The ArrayList uses indexof (O), as shown below:

    Vector v =new vector (5);    V.indexof (o, index);
    ArrayList ArrayList = new ArrayList ();    Arraylist.indexof (o);



The author's level is limited, welcome to add correct!



Reference documents

http://www.jb51.net/article/42767.htm the use and performance analysis of JAVA LinkedList and ArrayList

JAVA Vector and ArrayList usage and performance comparison

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.