79
Java ListIterator previousIndex() Method
The previousIndex() method of ListIterator interface is used to return the index of the given element which is returned by a call to previous. The method may return -1 if and only if the iterator is placed at the beginning of the list.
Syntax
Parameters
NA
Return
The above method is used to return the index of the given element which is returned by a call to previous. The method may return -1 if and only if the iterator is placed at the beginning of the list.
Example 1
Output:
The letters are listed as : [R, E, A, L] The Previous Index is : -1 The Previous Index is : 0 The Next Index is : 1 The Next index is : 2
Example 2
Output:
The numbers are listed as : [34, 78, 57] The Previous Index is : -1 The Previous Index is : 0 The Next Index is : 1
Next TopicJava ListIterator