

{"id":15783,"date":"2018-05-29T06:00:04","date_gmt":"2018-05-29T06:00:04","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=15783"},"modified":"2026-05-23T10:52:35","modified_gmt":"2026-05-23T05:22:35","slug":"java-iterator","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/java-iterator\/","title":{"rendered":"Learn Java Iterator &#8211; 3 Types of Iterator in Java"},"content":{"rendered":"<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:1933,&quot;href&quot;:&quot;https:\\\/\\\/docs.oracle.com\\\/javase\\\/7\\\/docs\\\/api\\\/java\\\/util\\\/Iterator.html&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20250929094317\\\/https:\\\/\\\/docs.oracle.com\\\/javase\\\/7\\\/docs\\\/api\\\/java\\\/util\\\/Iterator.html&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-10 11:47:18&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-21 13:55:25&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-26 08:43:52&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-13 16:40:31&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-03 08:42:50&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-11 12:57:04&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-15 05:52:46&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-22 10:13:01&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-05 06:07:02&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-12 04:08:54&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-01 12:48:57&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-01 12:48:57&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]'><\/div>\n<p>We discussed<strong><a href=\"https:\/\/data-flair.training\/blogs\/java-virtual-machine-jvm\/\" target=\"_blank\" rel=\"noopener\"> Java Virtual Machine<\/a><\/strong> in our last session. Here, we will talk about Java Iterator and how an iterator works in Java. Along with this, we will discuss enumeration with its example and syntax. Also, we will see Java Iterator and ListIterators with their limitation and examples.<\/p>\n<p><span style=\"font-weight: 400\">So, let us start with Java Iterators.<\/span><\/p>\n<div id=\"attachment_16709\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Java-Iterator-and-reflection-01-1.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-16709\" class=\"wp-image-16709 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Java-Iterator-and-reflection-01-1.jpg\" alt=\"Java Iterator\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Java-Iterator-and-reflection-01-1.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Java-Iterator-and-reflection-01-1-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Java-Iterator-and-reflection-01-1-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Java-Iterator-and-reflection-01-1-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Java-Iterator-and-reflection-01-1-1024x536.jpg 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-16709\" class=\"wp-caption-text\">Learn Java Iterator &#8211; 3 Types of Iterator in Java<\/p><\/div>\n<h3>What are iterators in Java?<\/h3>\n<p><span style=\"font-weight: 400\">Basically, <em>Java Iterators are used in Java for retrieving the elements one by one. They are used in the <\/em><a href=\"https:\/\/data-flair.training\/blogs\/collection-framework-in-java\/\" target=\"_blank\" rel=\"noopener\"><strong><em>Collection Framework<\/em> <\/strong><\/a>and\u00a0<\/span>allow us:<\/p>\n<ul>\n<li>To traverse the collection<\/li>\n<li>Access the Data Elements<\/li>\n<li>Delete the Element<\/li>\n<\/ul>\n<h3>Types of Java Iterators<\/h3>\n<p>Here, we are going to study three types of iterators in Java. Let&#8217;s discuss them one by one:<\/p>\n<h4>Enumeration in Java<\/h4>\n<p><span style=\"font-weight: 400\">It is an<a href=\"https:\/\/data-flair.training\/blogs\/interface-in-java\/\" target=\"_blank\" rel=\"noopener\"> <strong>interface<\/strong><\/a> used to get components of <a href=\"https:\/\/data-flair.training\/blogs\/inheritance-in-java\/\" target=\"_blank\" rel=\"noopener\"><strong>inheritance<\/strong><\/a> collections (Vector, Hashtable). Enumeration is the principal Java iterator introduced in JDK 1.0, rests incorporate into JDK 1.2 with greater functionality. Enumerations are additionally used for determining the information streams to a SequenceInputStream. We can make an Enumeration object by calling the elements() method for the vector class on any vector object.<\/span><\/p>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/java-assert\/\" target=\"_blank\" rel=\"noopener\">Do you know Why we use Assertion in Java<\/a><\/strong><\/p>\n<p><strong>Syntax of Java Iterators \u2013<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">Enumeration e = v.elements();\r\nThe two methods in enumeration interface are \u2013\r\n\/\/ Tests if this enumeration contains more elements\r\npublic boolean hasMoreElements();\r\n\/\/ Returns the next element of this enumeration\r\n\/\/ It throws NoSuchElementException\r\n\/\/ if no more element present\r\npublic Object nextElement();\r\n<\/pre>\n<p><strong>Example of Enumeration in Java \u2013<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">import java.util.Enumeration;\r\nimport java.util.Vector;\r\npublic class Test\r\n{\r\n   public static void main(String[] args)\r\n   {\r\n       Vector v = new Vector();\r\n       for (int i = 0; i &lt; 10; i++)\r\n           v.addElement(i);\r\n       System.out.println(v);\r\n       Enumeration e = v.elements();\r\n       while (e.hasMoreElements())\r\n       {\r\n           int i = (Integer)e.nextElement();\r\n           System.out.print(i + \" \");\r\n      }\r\n   }\r\n}<\/pre>\n<p><strong><span style=\"font-family: Verdana, Geneva, sans-serif\">Output:<\/span><\/strong><br \/>\n<span style=\"font-weight: 400\">[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]<\/span><br \/>\n<span style=\"font-weight: 400\">0 1 2 3 4 5 6 7 8 9<\/span><\/p>\n<p><strong>Limitations of Java Enumeration<\/strong><\/p>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">It is for a legacy class, and hence not a universal Java iterator.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">The operations of removal cannot be performed.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Only forward iteration is possible.<\/span><\/li>\n<\/ul>\n<h4>Java Iterator<\/h4>\n<p><span style=\"font-weight: 400\">It is a general (universal) Java iterator, as we can apply it to any collection object. By utilizing Java Iterator, we can perform both read and remove operations. It is an enhanced variant of Enumeration with the extra usefulness of the expelling capacity of an element.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Iterator must be utilized whenever we need to identify elements in all collection structure actualized interfaces like Set, List, Queue, Deque, and furthermore in every single executed class of the Map interface. Generally, Java iterators are the main cursor accessible for the whole collection Framework. <\/span><br \/>\n<span style=\"font-weight: 400\">We can make an Iterator operator by calling the iterator() strategy shown in the Collection interface.<\/span><\/p>\n<p><strong>A Syntax of Java Iterator \u2013<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">Iterator itr = c.iterator();\r\nIt basically has three methods \u2013\r\n\/\/ Returns true if the iteration has more elements\r\npublic boolean hasNext();\r\n\/\/ Returns the next element in the iteration\r\n\/\/ It throws NoSuchElementException if no more\r\n\/\/ element present\r\npublic Object next();\r\n\/\/ Remove the next element in the iteration\r\n\/\/ This method can be called only once per call\r\n\/\/ to next()\r\npublic void remove();<\/pre>\n<p><span style=\"font-weight: 400\">The remove iterator can throw two exceptions \u2013<\/span><\/p>\n<p>UnsupportedOperationException and IllegalStateException<\/p>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/java-date-and-time\/\" target=\"_blank\" rel=\"noopener\">Java Date and Time \u2013 Java Date Class &amp; GregorianCalendar Class<\/a><\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">import java.util.ArrayList;\r\nimport java.util.Iterator;\r\npublic class Test\r\n{\r\n   public static void main(String[] args)\r\n   {\r\n       ArrayList al = new ArrayList();\r\n       for (int i = 0; i &lt; 10; i++)\r\n           al.add(i);\r\n       System.out.println(al);\r\n       Iterator itr = al.iterator();\r\n       while (itr.hasNext())\r\n       {\r\n           int i = (Integer)itr.next();\r\n                       System.out.print(i + \" \");\r\n           if (i % 2 != 0)\r\n              itr.remove();\r\n       }\r\n       System.out.println();\r\n       System.out.println(al);\r\n   }\r\n}<\/pre>\n<p><strong><span style=\"font-family: Verdana, Geneva, sans-serif\">Output:<\/span><\/strong><br \/>\n<span style=\"font-weight: 400\">[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]<\/span><br \/>\n<span style=\"font-weight: 400\">0 1 2 3 4 5 6 7 8 9 <\/span><br \/>\n<span style=\"font-weight: 400\">[0, 2, 4, 6, 8]<\/span><\/p>\n<p><strong>Limitations of Java Iterator<\/strong><\/p>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Iteration in only the forward direction is possible.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Replacement and addition not possible.<\/span><\/li>\n<\/ul>\n<h3>ListIterator in Java<\/h3>\n<p><span style=\"font-weight: 400\">This is only applicable where there are List-implemented classes, such as ArrayList, linked list, etc. However, it provides the user with bi-directional iteration. It is used when we want to enumerate a list, and it has more functionality.<\/span><\/p>\n<p>The use of ListIterator is to go through the list and perform various operations on it.<\/p>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/java-array\/\" target=\"_blank\" rel=\"noopener\">Read Java Array Tutorial \u2013 Creating, Initializing, and Accessing Array in Java<\/a><\/strong><\/p>\n<div id=\"attachment_15918\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/ListIterator-01.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15918\" class=\"wp-image-15918 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/ListIterator-01.jpg\" alt=\"Java Iterator\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/ListIterator-01.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/ListIterator-01-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/ListIterator-01-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/ListIterator-01-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/ListIterator-01-1024x536.jpg 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-15918\" class=\"wp-caption-text\">Java Iterator- List Iterator<\/p><\/div>\n<p><span style=\"font-weight: 400\">Generally, we can create the list by using the listIterator() method, present in the List interface.<\/span><\/p>\n<p><span style=\"font-weight: 400\">ListIterator ltr = l.listIterator();<\/span><\/p>\n<p><span style=\"font-weight: 400\">It extends the Java iterator interface.<\/span><\/p>\n<p><strong>The 9 methods of listIterator in Java available are \u2013<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">\/\/ Forward direction\r\n\/\/ Returns true if the iteration has more elements<\/pre>\n<h4>i. public Boolean hasNext() in Java<\/h4>\n<p>This method returns a Boolean value if there is another element present next to the element where the cursor is pointing. It returns true if the next element is present, otherwise false.<\/p>\n<pre class=\"EnlighterJSRAW\">\/\/ same as next() method of Iterator<\/pre>\n<h4>ii. Java public Object next()<\/h4>\n<pre class=\"EnlighterJSRAW\">\/\/ Returns the next element index\r\n\/\/ or list size as required if the list iterator\r\n\/\/ is at the end of the list<\/pre>\n<h4>iii. public int nextIndex() in Java<\/h4>\n<pre class=\"EnlighterJSRAW\">\/\/ Backward direction\r\n\/\/ Returns true if the iteration has more elements\r\n\/\/ while traversing backward<\/pre>\n<h4>iv. public boolean hasPrevious() in Java<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\/\/ Returns the previous element in the iteration\r\n\/\/ and can throws NoSuchElementException\r\n\/\/ if no more element present<\/pre>\n<h4>v. Java public Object previous()<\/h4>\n<pre class=\"EnlighterJSRAW\">\/\/ Returns the previous element index\r\n\/\/  or -1 if the list iterator is at the\r\n\/\/ beginning of the list<\/pre>\n<p><strong style=\"font-family: Verdana, Geneva, sans-serif\"><a href=\"https:\/\/data-flair.training\/blogs\/java-method\/\" target=\"_blank\" rel=\"noopener\">Let&#8217;s explore Java Method &#8211; Declaration and Calling a Java Method<\/a><\/strong><\/p>\n<h4>vi. public int previousIndex() in Java<\/h4>\n<pre class=\"EnlighterJSRAW\">\/\/ Other Methods\r\n\/\/ same as remove() method of Iterator<\/pre>\n<h4>vii. Java public void remove()<\/h4>\n<pre class=\"EnlighterJSRAW\">\/\/ Replaces the last element returned by\r\n\/\/ next() or previous() with the specified element<\/pre>\n<h4>viii. public void set(Object obj) in Java<\/h4>\n<pre class=\"EnlighterJSRAW\">\/\/ Inserts the specified element into the list at\r\n\/\/ position before the element that would be returned\r\n\/\/ by next(),<\/pre>\n<h4>ix. Java public void add(Object obj)<\/h4>\n<p><span style=\"font-weight: 400\">Obviously, the three techniques that ListIterator acquires or inherits from Iterator (hasNext(), next(), and remove()) do the very same thing in the two interfaces. The hasPrevious() and the past tasks are correct analogs of hasNext() and next(). The previous tasks allude to the component before the (implicit) cursor, though the last allude to the component after the cursor. Therefore, the past activity moves the cursor in reverse, though next advances it.<\/span><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/literals-in-java\/\" target=\"_blank\" rel=\"noopener\"><strong>Literals in Java \u2013 Integral, Floating, Char, String, Boolean<\/strong><\/a><\/p>\n<p>Hence, ListIterator has no present component; its cursor position dependably lies between the element that would return by a call to previous() and the component that would return by a call to next()<\/p>\n<p><strong>set() technique can toss four special cases:<\/strong><\/p>\n<p><span style=\"font-weight: 400\"><span style=\"font-weight: 400\"><strong>1. UnsupportedOperationException: <\/strong><\/span><\/span>This exception arises when you have written the code to operate on the object, but it is against the object&#8217;s properties. For example, trying to update the array, but the size of the array doesn\u2019t change; it remains fixed when it is created.<\/p>\n<p><span style=\"font-weight: 400\"><strong>2. ClassCastException:<\/strong> If the class of the predetermined component keeps it from being added to this list.<\/span><\/p>\n<p><span style=\"font-weight: 400\"><strong>3. IllegalArgumentException:<\/strong> If some part of the predetermined element keeps it from being added to this list.<\/span><\/p>\n<p><span style=\"font-weight: 400\"><strong>4. IllegalStateException:<\/strong> If neither next nor past has been called, or expel or include have been called after the last call to previous or next.\u00a0<\/span><\/p>\n<p><strong>The add() strategy can toss three special cases:<\/strong><\/p>\n<p><span style=\"font-weight: 400\"><strong>1. UnsupportedOperationException:<\/strong> If they include a strategy that isn&#8217;t bolstered by this list.<\/span><\/p>\n<p><span style=\"font-weight: 400\"><strong>2. ClassCastException:<\/strong> If the class of the predefined component keeps it from, add to this list.<\/span><\/p>\n<p><span style=\"font-weight: 400\"><strong>3. IllegalArgumentException:<\/strong> If some part of this component keeps it from,\u00a0add to this list.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">import java.util.ArrayList;\r\nimport java.util.ListIterator;\r\npublic class Test\r\n{\r\n   public static void main(String[] args)\r\n   {\r\n       ArrayList al = new ArrayList();\r\n       for (int i = 0; i &lt; 10; i++)\r\n           al.add(i);\r\n       System.out.println(al);\r\n       ListIterator ltr = al.listIterator();\r\n       while (ltr.hasNext())\r\n       {\r\n           int i = (Integer)ltr.next();\r\n           System.out.print(i + \" \");\r\n           if (i%2==0)\r\n           {\r\n               i++;\r\n               ltr.set(i);\r\n               ltr.add(i);         }\r\n       }\r\n       System.out.println();\r\n       System.out.println(al);\r\n   }\r\n}<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<span style=\"font-weight: 400\">[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]<\/span><br \/>\n<span style=\"font-weight: 400\">0 1 2 3 4 5 6 7 8 9 <\/span><br \/>\n<span style=\"font-weight: 400\">[1, 1, 1, 3, 3, 3, 5, 5, 5, 7, 7, 7, 9, 9, 9]<\/span><\/p>\n<p><span style=\"font-weight: 400\">Only applicable to a list, not to a universal Java iterator.<\/span><\/p>\n<p>So, this was all about Java Iterator. Hope you like our explanation.<\/p>\n<h3>Conclusion<\/h3>\n<p><span style=\"font-weight: 400\">Hence, in this Java tutorial, we studied the Java Iterator. In conclusion, we discussed Java Iterators in Java, Enumeration, ListIterators with their example, limitations, and syntax. Along with this, we saw several methods for Java Iterator. Furthermore, if you have any queries, feel free to ask through the comment section.<\/span><\/p>\n<p><strong>See also &#8211;\u00a0<\/strong><strong><a href=\"https:\/\/data-flair.training\/blogs\/java-url-class\/\" target=\"_blank\" rel=\"noopener\">Java URL Class<\/a><\/strong><\/p>\n<p><a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/util\/Iterator.html\" target=\"_blank\" rel=\"noopener\"><strong>For reference<\/strong><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We discussed Java Virtual Machine in our last session. Here, we will talk about Java Iterator and how an iterator works in Java. Along with this, we will discuss enumeration with its example and&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":16709,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[4165,4295,5903,7339,7565,7566,8244,8687,8699,15773],"class_list":["post-15783","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-enumeration-in-java","tag-example-of-java-iterator","tag-how-iterator-works-n-java","tag-iterators-in-java","tag-java-iterator-methods","tag-java-iterators","tag-limitations-of-enumerations","tag-methods-in-java-iterators","tag-methods-used-in-java-iterator","tag-what-is-iterator-in-java"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Learn Java Iterator - 3 Types of Iterator in Java - DataFlair<\/title>\n<meta name=\"description\" content=\"Java Iterator, types of iterator in Java,enumeration,iterator,listiterators,limitation of java iterators,methods used in java iterator,java iterator example\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/java-iterator\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Learn Java Iterator - 3 Types of Iterator in Java - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Java Iterator, types of iterator in Java,enumeration,iterator,listiterators,limitation of java iterators,methods used in java iterator,java iterator example\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/java-iterator\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-05-29T06:00:04+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-05-23T05:22:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Java-Iterator-and-reflection-01-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Learn Java Iterator - 3 Types of Iterator in Java - DataFlair","description":"Java Iterator, types of iterator in Java,enumeration,iterator,listiterators,limitation of java iterators,methods used in java iterator,java iterator example","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/java-iterator\/","og_locale":"en_US","og_type":"article","og_title":"Learn Java Iterator - 3 Types of Iterator in Java - DataFlair","og_description":"Java Iterator, types of iterator in Java,enumeration,iterator,listiterators,limitation of java iterators,methods used in java iterator,java iterator example","og_url":"https:\/\/data-flair.training\/blogs\/java-iterator\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-05-29T06:00:04+00:00","article_modified_time":"2026-05-23T05:22:35+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Java-Iterator-and-reflection-01-1.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/java-iterator\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/java-iterator\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"Learn Java Iterator &#8211; 3 Types of Iterator in Java","datePublished":"2018-05-29T06:00:04+00:00","dateModified":"2026-05-23T05:22:35+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/java-iterator\/"},"wordCount":971,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/java-iterator\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Java-Iterator-and-reflection-01-1.jpg","keywords":["enumeration in java","Example of Java iterator","How iterator works n java","iterators in Java","java iterator methods","java iterators","limitations of enumerations","methods in java iterators","methods used in java iterator","what is iterator in java"],"articleSection":["Java Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/java-iterator\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/java-iterator\/","url":"https:\/\/data-flair.training\/blogs\/java-iterator\/","name":"Learn Java Iterator - 3 Types of Iterator in Java - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/java-iterator\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/java-iterator\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Java-Iterator-and-reflection-01-1.jpg","datePublished":"2018-05-29T06:00:04+00:00","dateModified":"2026-05-23T05:22:35+00:00","description":"Java Iterator, types of iterator in Java,enumeration,iterator,listiterators,limitation of java iterators,methods used in java iterator,java iterator example","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/java-iterator\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/java-iterator\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/java-iterator\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Java-Iterator-and-reflection-01-1.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Java-Iterator-and-reflection-01-1.jpg","width":1200,"height":628,"caption":"Java Iterator"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/java-iterator\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Java Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/java\/"},{"@type":"ListItem","position":3,"name":"Learn Java Iterator &#8211; 3 Types of Iterator in Java"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/15783","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=15783"}],"version-history":[{"count":10,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/15783\/revisions"}],"predecessor-version":[{"id":148439,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/15783\/revisions\/148439"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/16709"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=15783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=15783"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=15783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}