JAVA-VECTOR__J2SE Technology

Source: Internet
Author: User

For the list interface, it also introduces an implementation class Vector,vector class that can be implemented to grow an array of objects. I. Vector introduction

Vectors can implement an array of objects that can grow. Like an array, it contains components that can be accessed using an integer index. However, the size of the vector can be increased or decreased to accommodate additions or deletions after the vector is created.

Vector implementation of the list interface, inherit the Abstractlist class, so we can consider it as a queue, support related additions, deletions, modifications, traversal and other functions.

Vector implements the Randmoaccess interface, which provides a random access feature that provides fast access. In vector we can access elements directly.

Vector implements the Cloneable interface, supports the Clone () method, and can be cloned.

[Java] view plain copy print? public class Vector<e> extends abstractlist<e> implements List<e>, Randomaccess, Cloneable, Java.io.Serializable

The vector provides four constructors:

[Java]  View plain copy print? /**       *  constructs an empty vector so that its internal data array size is &NBSP;10 and its standard capacity increment is zero.        */        public vector ()  {                this (;  )      }              /**        *  constructs a vector containing the elements in the specified  collection , which are based on their  collection  The iterator returns the order of the elements.        */       public vector (collection<? &NBSP;EXTENDS&NBSP;E&GT;&NBSP;C)  {           elementdata  = c.toarray ();           elementCount =  elementdata.length;           // c.toArray might  (incorrectly)  not return Object[]  (see 6260652)             if  (Elementdata.getclass ()  != object[].class)                elementdata = arrays.copyof ( elementdata, elementcount,                        object[].class);       }               /**        *  constructs an empty vector using the specified initial capacity and the capacity increment equal to zero.        */       public vector (int  initialcapacity)  {           this (initialcapacity,  0);       }          &Nbsp;   /**       *   constructs an empty vector using the specified initial capacity and capacity increment.        */       public vector (int  initialcapacity, int capacityincrement)  {            super ();           if  (initialcapacity <  0)                throw new  illegalargumentexception ("illegal capacity: " +                                                     initialcapacity);           

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.