在这个例子中,我们使用Enumeration
迭代Vector
。步骤如下:
1)创建一个Vector
对象
2)使用Vector
类的add()
方法向向量添加元素。
3)调用elements()
方法获取指定Vector
的枚举
4)使用Enumeration
方法hashMoreElements()
和nextElement()
迭代Vector
。
示例:完整代码
输出:
在这个例子中,我们使用Enumeration
迭代Vector
。步骤如下:
1)创建一个Vector
对象
2)使用Vector
类的add()
方法向向量添加元素。
3)调用elements()
方法获取指定Vector
的枚举
4)使用Enumeration
方法hashMoreElements()
和nextElement()
迭代Vector
。
示例:完整代码
输出: