提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
替换向量的所有元素
import java.util.Vector; import java.util.Collections; /**nowjava - 时代Java**/ public class Main { public static void main(String[] args) { Vector v = new Vector(); v.add("A"); v.add("B"); v.add("D"); System.out.println("Before replacement, Vector contains : " + v); Collections.fill(v,"REPLACED"); System.out.println("After replacement, Vector contains : " + v); } } /*NowJava.com - 时 代 Java*/