如题,谢谢了

解决方案 »

  1.   


    从Vector里面一个一个取出来,然后强制转换装入int类型的数组。
      

  2.   

    Vector中只能添加Object,使用Vector.toArray(new Integer[0])也只能转化为Integer数组,不能直接转化成int[]
      

  3.   

    Vector中存放的是Object类型的数据,如果您确认放入的数据是int型的或者是Integer类型的,那就读出来,放入到int数组中就可以了
    如果存放的数据不能通过转化变成int型的,那就没办法操作了
      

  4.   

    import java.util.Vector;public class Test1 { public static void main(String[] args) {
    Vector v = new Vector();
    v.add("1");
    v.add("2");
    int[] ss = new int[2];
    for(int i=0;i<2;i++){
    ss[i] = Integer.parseInt((String) v.get(i));
    System.out.println(ss[i]);
    }
    }
    }
    我只是举个例子,这样应该可以的
      

  5.   

    import java.util.Vector; public class Test1 { public static void main(String[] args) { 
    Vector v = new Vector(); 
    v.add("1"); 
    v.add("2"); 
    int[] ss = new int[2]; 
    for(int i=0;i <2;i++){ 
    ss[i] = Integer.parseInt((String) v.get(i)); 
    System.out.println(ss[i]); 



    这种方式只能是在知道集合中数据的时候才能啊,还要得到集合length()。size()都可以
      

  6.   

    Vector vec = new Vector;
      // Populate it... Then later, iterate over its elements
      Iterator it = vec.iterator ();
      while (it.hasNext ()) {
        Object o = it.next ();
      }
    Therefore, when retrieving an object from one of the containers, it can only be returned as a Object type. In most cases, you need to cast the retrieved Object to the specific object type you desire. You should know what kind of objects you store into a container, so you can do the cast correctly.If, however, you cast a returned Object to a type that it does not represent (say, you cast an Integer to a String), the program will fail due to a runtime ClassCastException.