//Demonstrate various vector operations.
import java.util.*;
class VectorDemo{
public static void main(String[] args)
{
//initial size is 3,increment is 2
Vector v = new Vector(3,2);
System.out.println("Initial size :" + v.size());
System.out.println("Initial Capacity :" + v.capacity());
v.addElement(new Integer(1));
v.addElement(new Integer(2));
v.addElement(new Integer(3));
v.addElement(new Integer(4));
System.out.println("Capacity after four additions:" + v.capacity());
v.addElement(new Double(9.99));
System.out.println("Current capacity :" + v.capacity());
v.addElement(new Double(77.87));
v.addElement(new Integer(9));
System.out.println("Current capacity :" + v.capacity());
v.addElement(new Float(77.7));
v.addElement(new Integer(10));
System.out.println("Current capacity :" + v.capacity());
v.addElement(new Integer(11));
v.addElement(new Integer(12));
System.out.println("First element :" + (Integer)v.firstElement());
System.out.println("Last element :" + (Integer)v.lastElement());
if(v.contains(new Integer(3)))
System.out.println("Vector contains 3.");
//enumerate the elements in the vector
Enumeration enum = v.elements();
System.out.println("Elements in vector:");
while(enum.hasMoreElements()){
System.out.print(enum.nextElement() + " ");
}
System.out.println();
/*
//use an iterator to display contents
Iterator i = v.iterator();
System.out.println("Elements in vector:");
while(i.hasNext()){
System.out.print(i.next() + " ");
}
System.out.println();
*/
}
}
分享到:
相关推荐
USB枚举过程 USB Enumeration
经我细心探究,终于把J2ME中的Enumeration排序问题给解决了
Access-based Enumeration Windows Server 2003安装包
NULL 博文链接:https://chaoyi.iteye.com/blog/2085158
cwe_latest 2021 common weakness enumeration.pdf
java枚举类型详细讲解,自己撰写的一本电子书,编写得很详细
Network Enumeration .To keep me from implementing such a task over and over again枚举网络资源
Windows.Devices.Enumeration
linux-smart-enumeration-master.zip
jsp使用session示例,以网上购物为例子,说明session的使用方法,说明Enumeration的方法
首先,几个有用的one...linux-smart-enumeration 用于渗透测试和CTFLinux枚举工具 该项目的灵感来自并使用了许多测试。 不像LINENUM, lse尝试gradualy揭露根据其重要性从一个privesc点的信息。 它是什么? 该She
Enumeration和Iterator接口功能相似,而且Iterator的功能还比Enumeration多,那么为什么还要使用Enumeration
CP2102驱动,CP2102具有集成度高的特点,可内置USB2.0全速功能控制器、USB收发器、晶体振荡器、EEPROM及异步串行数据总线(UART),支持调制解调器全功能信号,无需任何外部的USB器件。
下面小编就为大家带来一篇详谈Enumeration接口和Iterator接口的区别。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
Iterator与Enumeration分别是实现迭代器和枚举器类的接口,下面就带大家来详解Java中的迭代迭代器Iterator与枚举器Enumeration,以及它们之间的区别.
Java 实例 - 使用 Enumeration 遍历 HashTable源代码+详细指导教程.zip
资源分类:Python库 所属语言:Python 资源全名:django-enumeration-0.1.2.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
Enumeration of spanning trees in planar unclustered networks
SUMS55 An Introduction to Enumeration, Alan Camina, Barry Lewis (2011) .zip