public Vector(Collection<? extends E> 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);
    }红色字体
谢谢

解决方案 »

  1.   



     public Vector(Collection<? extends E> 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);
        }

    public Vector(Collection<? extends E> c)
      

  2.   

    Collection表示集合,<>表示范型,总的表示传入一个集合元素为object的子类的集合
      

  3.   


    ?:表示通配符;E:表示Collection里的Element(元素);
    第二个参数 Collection<? extends E> c 表示的是 Collection c中的元素只能是E及其子类的对象。而泛型E只有E的对象。还有这种形式的List<? Super Child>声明的List 能且仅能存放Child及其父类对象.
      

  4.   

    你也可以查API文档
    boolean addAll(Collection<? extends E> c)将指定 collection 中的所有元素都添加到此 collection 中(可选操作)。如果在进行此操作的同时修改指定的 collection,那么此操作行为是不确定的。(这意味着如果指定的 collection 是此 collection,并且此 collection 为非空,那么此调用的行为是不确定的。) 参数:
    c - 包含要添加到此 collection 的元素的 collection 
    返回:
    如果此 collection 由于调用而发生更改,则返回 true 
    抛出: 
    UnsupportedOperationException - 如果此 collection 不支持 addAll 方法 
    ClassCastException - 如果指定 collection 中某个元素的类不允许它添加到此 collection 中 
    NullPointerException - 如果指定 collection 包含 null 元素,并且此 collection 不支持 null 元素,或者指定的 collection 为 null 
      

  5.   

    这就是泛型的限定符,如果要看懂的话,最好看看Java的泛型中对于wildcard的描述
      

  6.   

    Vector 不是过期了么,怎么还用他,都用ArrayList了····