VOOZH about

URL: https://www.geeksforgeeks.org/java/java-collections-emptyiterator-method-with-examples/

⇱ Java Collections emptyIterator() Method with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Java Collections emptyIterator() Method with Examples

Last Updated : 3 Jan, 2022

The emptyIterator() method of Java Collections returns an iterator with no elements. This method is immutable. That is, we can not do any modifications after creating this method.

Syntax:

Iterator<data_type> object = Collections.emptyIterator(); 

where,

  • data_type is the type of iterator object
  • object is the data to create an iterator

Parameters: It will accept no parameters.

Return Type: It will return an empty iterator.

Exceptions: It will not raise any exceptions.

Example 1:


Output
java.util.Collections$EmptyIterator@3d075dc0

Example 2:


Output
false
Comment