Vector of JAVA data structures

Source: Internet
Author: User

Vector implements a dynamic array. is an array of objects that can be automatically grown.

Comparison of vectors and ArrayList:

1, all in an array format to store data, index data block insert data slow

2, ArrayList will be faster than vector, he is non-synchronous

3, involving multi-threading, vector is a better synchronization

Usage:

1. Constructor:

1) Construction method creates a default vector with a default size of ten:vector()

2) Construction method creates a vector of the specified size: vector (int size)

3) The construction method creates a vector of the specified size, and the increment is specified with incr. Increments indicate the number of elements each increment of the vector: Vector(int size,int incr)

4) construct a vector that contains the C elements of the collection: Vector(Collection c)

2. Insert the specified element into the specified position: V.add (i,element)

3. Insert element on the last surface: V.add (Element)

4. Clear all elements: V.clear ()

5. Determine if an element is included: V.contains (Element) returns TRUE or V.indexof (element) returns subscript

6. Return the element referred to in the subscript: V.elementat (i)

7, Comparison is equal: V.equals (Element)

8. Determine if it is empty: V.isempty ()

9. Remove an element: V.remove (I | element)

10. Return Size: V.size ()

11. Set an element for a subscript store: V.set (i,element)

12. Convert to Array: V.toarray ()

13. Convert to String: v.tostring ()

Vector of JAVA data structures

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.