Java Vector listIterator() Method24 Mar 2025 | 3 min read The listIterator() Java Vector class method returns a list iterator over the elements in the given list in a proper sequence. There is two different types of Java listIterator() method which can be differentiated depending on its parameter. These are:
listIterator() Method:This method is used to get a list iterator over the elements in the given list in a proper sequence. listIterator(int index) Method:This method is used to get a list iterator over the elements in the given list in a proper sequence. The returned list starts at the specified position in the list. The specified index indicates the first element that would be returned by an initial call to next. SyntaxFollowing is the declaration of listIterator() method: Parameter
ReturnThe listIterator() method returns a list iterator over the elements in this list in a proper sequence. ExceptionsIndexOutOfBoundsException- This method has thrown an exception if the index is out of range i.e. (index < 0 || index > size()). Compatibility VersionJava 1.2 and above Example 1Output: Iterate elements are: Two Three Four Five Example 2Output: Iterate elements are: Orange Mango Banana Apple Example 3Output: Iterate elements are: 1 2 3 4 5 Example 4Output: Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 25 at java.base/java.util.Vector.listIterator(Vector.java:1234) at myPackage.VectorListIteratorExample4.main(VectorListIteratorExample4.java:12) Next TopicJava Vector |
Java Method The copyInto() method of Java Vector class used to copy the elements of the vector which is in use into the specified array. In this, the position of the elements is the same in both the vector and an array. Syntax: Following is the declaration...
3 min read
Java Method The remove() Java Vector class method is used to remove the specified element from the vector. There are two different types of Java remove() method which can be differentiated depending on its parameter. These are: Java Vector remove(int index) Method Java Vector remove(Object o) Method remove(int...
3 min read
Java Method The isEmpty() method of Java Vector class is used to check if this vector has no components. It returns true if the vector is empty, otherwise returns false. Syntax Following is the declaration of isEmpty() method: Public boolean isEmpty() Parameter This method does not accept any parameter. Return The isEmpty()...
3 min read
Java Method The toArray() Java Vector class method is used to get an array containing all of the elements in this vector in the correct order. There is two different types of Java toArray() method which can be differentiated depending on its parameter. These are: Java...
3 min read
Java Method The elements() method of Java Vector class used to get an enumeration of the elements of the vector which is in use. The returned enumeration object will generate all items in this vector at the same location. Syntax: Following is the declaration of elements() method: public...
2 min read
Java Method The iterator() method of Java Vector class is used to get an iterator over the elements in this list in proper sequence. Syntax Following is the declaration of an iterator() method: Public Iterator<E> iterator() Parameter This method does not accept any parameter. Return The iterator() method returns an iterator over...
2 min read
Java Method The indexOf() Java Vector class method is used to get the index of the first occurrence of the specified element in the vector. There are two different types of Java indexOf() method which can be differentiated depending on its parameter. These are: Java Vector...
3 min read
Java Method The setElementAt() method of Java Vector class is used to replace the component at the specified index of this vector to be the specified object. Syntax Following is the declaration of setElementAt() method: public void setElementAt(E obj, int index) Parameter Parameter Description Required/Optional index It is the specified index where an element...
2 min read
Java Method The capacity() method of Java Vector class is used to get the current capacity of the vector which is in use. Syntax: Following is the declaration of capacity() method: Public int capacity() Parameter: This method does not accept any parameter. Returns: This method returns the current capacity of the vector...
2 min read
Java Method The hashCode() method of Java Vector class is used to get the hashcode value for the vector which is in use. Syntax: Following is the declaration of hashCode() method: public int hashCode() Parameter: This method does not accept any parameter. Returns: The hashCode() method returns the hash code value for...
2 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India