在上一个教程中,我们分享了如何[将 Vector 转换为数组](https://beginnersbook.com/2014/07/how-to-convert-vector-to-string-array-in-java/"How to convert Vector to String array in java")。在这里,我们将通过示例看到 Vector to ArrayList 转换。
在下面的代码片段中,我们有一个[Vector](https://beginnersbook.com/2013/12/vector-in-java/"Vector in Java") 的字符串,我们将其转换为字符串的 [ArrayList](https://beginnersbook.com/2013/12/java-arraylist/"ArrayList in java with example programs – Collections Framework") 。我们在下面的示例中遵循的步骤是:
在这个例子中,我们使用[Enumeration](https://docs.oracle.com/javase/7/docs/api/java/util/Enumeration.html) 迭代 [Vector](https://beginnersbook.com/2013/12/vector-in-java/"Vector in Java")。步骤如下:
在上一个教程中,我们学习了如何[使用 ListIterator](https://beginnersbook.com/2014/06/vector-listiterator-example-in-java/"Vector ListIterator example in Java") 在两个方向(前进和后退)中遍历 Vector。在这个例子中,我们将看到如何使用 [Iterator](https://beginnersbook.com/2014/06/java-iterator-with-examples/"Java Iterator with examples") 遍历 [Vector](https://beginnersbook.com/2013/12/vector-in-java/"Vector in Java")。步骤如下:
我们可以使用[ListIterator](https://beginnersbook.com/2014/06/listiterator-in-java-with-examples/"ListIterator in Java with examples") 在前进和后退方向上遍历 [Vector](https://beginnersbook.com/2013/12/vector-in-java/"Vector in Java") 。除此之外,我们还可以使用 ListIterator API 的方法执行其他几个操作,例如显示下一个和前一个元素的索引,替换元素值,在迭代期间删除元素等。
我们可以使用[`ListIterator`](https://beginnersbook.com/2014/06/listiterator-in-java-with-examples/)在前进和后退方向上遍历[`Vector`](https://beginnersbook.com/2013/12/vector-in-java/)。除此之外,我们还可以使用 `ListIterator` API 的方法执行其他几个操作,例如显示下一个和前一个元素的索引,替换元素值,在迭代期间删除元素等。