Java ArrayList listIterator() method

The listIterator () method of Java ArrayList returns a list iterator over the elements in this list starting at the specified position in this list. The specified index indicates the first element that would be returned by an initial call to next. An initial call to previous would return the element with the specified index minus one.

Syntax:

Parameter:

"index": is the index of the first element to be returned from the list iterator when calling iterator.next () method.

Return:

Return "ListIterator": returns list iterator over the elements in this list starting at the specified position in this list.

Exception:

IndexOutOfBoundsException:If the index is out of range (index<0 || index > size).

Example 1

Test it Now

Output:

[d, dd, ddd, dddd, ddddd]
ddd
dddd
ddddd

Example 2

Test it Now

Output:

[d, dd, ddd, dddd, ddddd]
false
IndexOutOfBoundsException

Next TopicJava ArrayList




Latest Courses