Home » Java ListIterator nextIndex() Method with Examples

Java ListIterator nextIndex() Method with Examples

by Online Tutorials Library

Java ListIterator nextIndex() Method

The nextIndex() method of ListIterator interface is used to return the index of the element which is returned by the next() method.

Syntax

Parameters

NA

Return

The above method is used to return the index of the element which is returned by the next() method. The method may also return the list size only if the list iterator is placed at the end of the list.

Example 1

Test it Now

Output:

The vehicles are listed as :[Scooter, Car, Truck, Bike]  The first Index is given as : 0  The second Index is given as : 1  The third index is given as : 2  The fourth index is given as : 3  

Example 2

Test it Now

Output:

The marks are listed as : [22.4, 34.98, 12.9, 76.4]  The first Index is given as : 0  The second Index is given as : 1  The third index is given as : 2  The fourth index is given as : 3  

Example 3

Test it Now

Output:

The ages are listed as :[5, 10, 15, 20]  The first Index is given as : 0  The second Index is given as : 1  The third index is given as : 2  The fourth index is given as : 3  

You may also like