提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
向量所有元素的反序
/** * N o w J a v a . c o m 提 供 **/ import java.util.Vector; import java.util.Collections; public class Main { public static void main(String[] args) { Vector v = new Vector(); v.add("A"); v.add("B"); v.add("C"); v.add("D"); v.add("E"); // from 时代Java公众号 System.out.println("Before Reverse Order, Vector Contains : " + v); Collections.reverse(v); System.out.println("After Reverse Order, Vector Contains : " + v); } }