VOOZH about

URL: https://www.geeksforgeeks.org/java/absractcollection-iterator-method-in-java-with-examples/

⇱ AbsractCollection iterator() Method in Java with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

AbsractCollection iterator() Method in Java with Examples

Last Updated : 11 Jul, 2025
The iterator() method of Java AbstractCollection is used to return an iterator of the same elements as that of the Collection. The elements are returned in random order from what was present in the Collection. Syntax:
Iterator iterate_value = AbstractCollection.iterator();
Parameters: The function does not take any parameter. Return Value: The method iterates over the elements of the Collection and returns the values(iterators). Below programs illustrate the use of AbstractCollection.iterator() method: Program 1:
Output:
Collection: [4, Geeks, To, Welcome]
The iterator values are: 
4
Geeks
To
Welcome
Program 2:
Output:
Collection: [Welcome, To, Geeks, 4, Geeks]
The iterator values are: 
Welcome
To
Geeks
4
Geeks
Comment