提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
获取向量子列表
/*N o w J a v a . c o m*/ import java.util.Vector; import java.util.List; public class Main { public static void main(String[] args) { //create Vector object Vector v = new Vector(); //Add elements to Vector v.add("1"); v.add("2"); v.add("3"); /** NowJava.com 提供 **/ v.add("4"); v.add("5"); List lst = v.subList(1,3); //display elements of sub list. System.out.println("Sub list contains : "); for(int i=0; i< lst.size() ; i++) System.out.println(lst.get(i)); //remove one element from sub list Object obj = lst.remove(0); System.out.println(obj + " is removed from sub list"); //print original Vector System.out.println(