Java Collections emptyListIterator() Method

21 Mar 2025 | 1 min read

The emptyListIterator() method of Java Collections class is used to get a List Iterator that has no elements.

Syntax

Following is the declaration of emptyListIterator() method:

Parameter

This method does not accept any parameter.

Returns

The emptyListIterator() method returns the list Iterator that has no elements..

Exceptions

NoSuchElementException

Compatibility Version

Java 1.7 and above

Example 1

Output:

 Output: false 

Example 2

Output:

 Exception in thread "main" java.util.NoSuchElementException	at java.base/java.util.Collections$EmptyIterator.next(Collections.java:4190)	at myPackage.CollectionsEmptyListIteratorExample2.main(CollectionsEmptyListIteratorExample2.java:10) 

Example 3

Output:

 0 -1 nextIndex() and previousIndex() always returns 0 and -1.