Java Collections emptyListIterator() MethodThe emptyListIterator() method of Java Collections class is used to get a List Iterator that has no elements. SyntaxFollowing is the declaration of emptyListIterator() method: ParameterThis method does not accept any parameter. ReturnsThe emptyListIterator() method returns the list Iterator that has no elements.. ExceptionsNoSuchElementException Compatibility VersionJava 1.7 and above Example 1Test it NowOutput: Output: false Example 2Test it NowOutput: 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 3Test it NowOutput: 0 -1 nextIndex() and previousIndex() always returns 0 and -1. Next TopicJava Collections Class |
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