vectordeldemo.java
来自「JAVA编程思想源代码 值得一下 很难找的」· Java 代码 · 共 37 行
JAVA
37 行
package chapter9;
import java.util.Vector;
public class VectorDelDemo {
public static void main(String[] args) {
Vector<String> v = new Vector<String>(5,1);
for(int i=0;i<20;i++){
int j=i;
if(j>=10)
j=j-10;
v.addElement(String.valueOf(j));
}
System.out.println("初始v为:" + v);
System.out.println("初始v的大小为:" + v.size());
System.out.println("初始v的容量为:" + v.capacity());
v.removeElement("2");
System.out.println("removeElement(\"2\")后v为:" + v);
System.out.println("removeElement(\"2\")后v的大小为:" + v.size());
System.out.println("removeElement(\"2\")后v的容量为:" + v.capacity());
v.removeElementAt(2);
System.out.println("removeElementAt(2)后v为:" + v);
System.out.println("removeElementAt(2)后v的大小为:" + v.size());
System.out.println("removeElementAt(2)后v的容量为:" + v.capacity());
v.removeAllElements();
System.out.println("removeAllElements()后v为:" + v);
System.out.println("removeAllElements()后v的大小为:" + v.size());
System.out.println("removeAllElements()后v的容量为:" + v.capacity());
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?