Java数组与vector互转
/* Object[] object1 = null ; //数组定义 Vector<Object> object2;//Vector定义 object2 = new Vector<Object>(Arrays.asList(object1));// array -> vector object1 = object2 .toArray( new Object[object2 .size()]);// vector ->array */ Integer[] object1={0,10,20,30,40,50,60,70,80,90,100};//数组定义 Vector<Integer> object2;//Vector定义 object2=new Vector<Integer>(Arrays.asList(object1));//[] -> array -> vector System.err.println(Arrays.toString(object1)); System.err.println(object2); Integer[] object3 = object2.toArray(new Integer[object2.size()]);//vector -> array -> [] System.out.println(Arrays.toString(object3));
时间: 2024-11-25 01:31:52