如何给1个vector对象中vector对象的元素赋值,要切实真确的,通过编译的,不要给伪代码
                        
                     ((Vector)vector.elementAt(row)).elementAt(col)=value;//value为string对象
                              
                  好像不能用等号赋值,是不时用addElement方法,但是第Vector对象的vector对象的
                               add方法 怎点不出来

解决方案 »

  1.   


    import java.util.Vector;public class jiecheng {    public static void main(String[] args) {
            Vector<Vector<String>> vector = new Vector<Vector<String>>();
            Vector<String> v = new Vector<String>();
            v.add("hello");
            vector.add(v);
            vector.elementAt(0).add("world!");
            System.out.println(v);
        }
    }
      

  2.   

     ( (Vector)((Vector)vector.elementAt(row)).elementAt(col)).add("hello");
    应该再加一层强制转换,因为你调用的elementAt的时候(第二次)它又变成Objec和类型了,不是Vector类型了,所以要强转一下,个人看法,不一定对,你参考一下吧
      

  3.   

    不用泛型,就使用在vector中添加vector对象能实现吗