package baibai.learn;import java.util.Vector;public class LearnVector {
Vector vector;

/**
 * Method LearnVector
 *
 *
 */
public LearnVector() {
vector = new Vector();
vector.add(this.vector);
}

public static void main(String[] args) {
System.out.println(((Vector)new LearnVector().vector.get(0)).get(0));
}
}
我这样写都没有出问题啊,输出是:[(this Collection)]
你最好把源代码贴出来看看

解决方案 »

  1.   

    应该可以。不过Vector的效率不高,推荐你用ArrayList。
      

  2.   

    另外说一下,用Vector不如用ArrayList。
      

  3.   

    当然可以.
    注意Vector 是同步的,而ArrayList 是异步的.
      

  4.   

    public static Vector getPowerSet(Vector inset){
    Vector temp=new Vector();
    Vector res=new Vector();
    Vector last=null;
    for(int i=0;i<inset.size();i++){
    temp=new Vector(res);
    for(int j=0;j<temp.size();j++){
    System.out.println(temp.get(j).toString());
    ((Vector)temp.get(j)).add(inset.get(i).toString());
    System.out.println(temp.get(j).toString());
    }
    last=new Vector();
    last.add(inset.get(i).toString());
    temp.add(last);
    res.addAll(temp);
    }
    return res;
    }
      

  5.   

    temp里面的每一个element不是vector了,是res那个vector中的每一个element!
    这是你用的构造器说明:
    Vector
    public Vector(Collection c)Constructs a vector containing the elements of the specified collection, in the order they are returned by the collection's iterator. Parameters:
    c - the collection whose elements are to be placed into this vector. 
    Throws: 
    NullPointerException - if the specified collection is null.
    Since: 
    1.2 
      

  6.   

    我的temp和res
    一样、都是元素是Vector的Vector?
    我感觉没错阿?
    哪个地方有问题?
      

  7.   

    public Vector(Collection c)  生成的是指向c的引用吗?
    为什么我第一步temp=new Vector(res);以后再做
    for(int j=0;j<temp.size();j++){
    System.out.println(temp.get(j).toString());
    ((Vector)temp.get(j)).add(inset.get(i).toString());
    System.out.println(temp.get(j).toString());
    } 就改变了res的值?????????
      

  8.   

    肯定可以 因为只有数组是可以存储基本类型数据的
    其他容器都是存储Object引用的 
    另外 : Vector 实际是比较旧的容器了  不过它又是线程安全的
      

  9.   

    可以,vector中放的是object,一个vector本身就是一个object,所以可以放进去。
      

  10.   

    只要是java.lang.Object的子类,都可以啊。