vector 向量,存放对象的可变数组

解决方案 »

  1.   

    java.util 
    Class Vector
    java.lang.Object
      |
      +--java.util.AbstractCollection
            |
            +--java.util.AbstractList
                  |
                  +--java.util.VectorAll Implemented Interfaces: 
    Cloneable, Collection, List, RandomAccess, Serializable 
    Direct Known Subclasses: 
    Stack --------------------------------------------------------------------------------public class Vector
    extends AbstractList
    implements List, RandomAccess, Cloneable, Serializable
    The Vector class implements a growable array of objects. Like an array, it contains components that can be accessed using an integer index. However, the size of a Vector can grow or shrink as needed to accommodate adding and removing items after the Vector has been created.Each vector tries to optimize storage management by maintaining a capacity and a capacityIncrement. The capacity is always at least as large as the vector size; it is usually larger because as components are added to the vector, the vector's storage increases in chunks the size of capacityIncrement. An application can increase the capacity of a vector before inserting a large number of components; this reduces the amount of incremental reallocation. As of the Java 2 platform v1.2, this class has been retrofitted to implement List, so that it becomes a part of Java's collection framework. Unlike the new collection implementations, Vector is synchronized.The Iterators returned by Vector's iterator and listIterator methods are fail-fast: if the Vector is structurally modified at any time after the Iterator is created, in any way except through the Iterator's own remove or add methods, the Iterator will throw a ConcurrentModificationException. Thus, in the face of concurrent modification, the Iterator fails quickly and cleanly, rather than risking arbitrary, non-deterministic behavior at an undetermined time in the future. The Enumerations returned by Vector's elements method are not fail-fast. Since:
    JDK1.0 
    See Also:
    Collection, List, ArrayList, LinkedList, Serialized Form
      

  2.   

    表示矢量可以用来代替数组主要不同是vector的长度可以自动增长而数组不行
      

  3.   

    普通数组长度不可变,而vector长度可变,但它只能存储对象
      

  4.   

    类似于集合。可作为动态数组使用。可以存储任何内容,同一个Vector可以存储Integer,String,以及任何类(包括Vector)。可以实现复杂的数据结构
    为了存储一个简单类型,需要转为一个对象,eg:int->Integer
      

  5.   

    可以说java的应用是安全指针!