- Implementation method
First Vector is from JDK1.2 on the provision of List the implementation , Vector and the ArrayList is also implemented based on arrays
- Construction method
Create a size of Ten array, and assigns values to the Elementdata object, and the capacityincrement set to 0
- Insert object: Add (E)
Vectorin theAddmethod increases thesynchronizedkeyword, so this method is thread-safe, except that he andArrayListbasically the same, the difference is that when the array size is not enough, the amplification strategy is different (ifcapacityincrementGreater than0, you willobjecthe continuation of the array oh ah expand for nowsizeon the pluscapacityincrementthe value, ifcapacityincrementequals less than0, you willObjectthe size of the array is exaggerated for the existingsizeof twice times)
- Delete object: Remove (E)
in addition to its invocation of the removeelement method has synchronized keywords outside, and arrayList exactly the same
- Get a single object: Get (Index)
out of the way there's syhchronized keywords, Implementing and ArrayList same
- Traversing objects: iterator ()
and the ArrayList exactly the same
- To determine whether an object exists: contains (E)
and the ArrayList The only difference is indexOf method has synchronized Key Words
- Attention points
Vector is based on synchronized implemented thread-safe ArrayList , amplification methods and ArrayList slightly different, you can pass in capacityincrement to control the expansion of capacity
Vector collection in-depth learning