提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
从向量中删除所有元素
/* from n o w j a v a . c o m - 时 代 Java */ import java.util.Vector; public class Main { public static void main(String[] args) { Vector v = new Vector(); //Add elements to Vector v.add("1"); v.add("2"); v.add("3"); System.out.println("Size of Vector before removing elements : " + v.size()); v.clear();/*N o w J a v a . c o m - 时代Java 提供*/ //OR v.removeAllElements(); System.out.println("Size of Vector after removing elements : " + v.size()); } }