📄 vectordeldemo.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -