你的位置:首页 > Java教程

[Java教程]Java数组与vector互转


Java数组与vector互转

 

/*Object[] object1 = null ; //数组定义Vector<Object> object2;//Vector定义object2 = new Vector<Object>(Arrays.asList(object1));// array -> vectorobject1 = 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 -> vectorSystem.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));