Vector类
- 数组结构实现,查询块、增删慢。
- JDK1.0版本加入,运行效率慢、线程安全。
1. Vector
Vector<String> vector = new Vector<>();
vector.add("tang");
vector.add("he");
vector.add("yu");
System.out.println("元素个数:" + vector.size());
Enumeration<String> enumeration = vector.elements();
while (enumeration.hasMoreElements()) {
String s = (String) enumeration.nextElement();
System.out.println(s);
}
System.out.println(vector.isEmpty());
System.out.println(vector.contains("he"));
Vector<String> vector = new Vector<>();
vector.add("tang");
vector.add("he");
vector.add("yu");
System.out.println("元素个数:" + vector.size());
Enumeration<String> enumeration = vector.elements();
while (enumeration.hasMoreElements()) {
String s = (String) enumeration.nextElement();
System.out.println(s);
}
System.out.println(vector.isEmpty());
System.out.println(vector.contains("he"));