{"id":208,"date":"2024-07-30T06:52:39","date_gmt":"2024-07-30T06:52:39","guid":{"rendered":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/chapter\/introduction-12\/"},"modified":"2026-03-16T14:30:43","modified_gmt":"2026-03-16T14:30:43","slug":"introduction-12","status":"publish","type":"chapter","link":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/chapter\/introduction-12\/","title":{"raw":"Introduction","rendered":"Introduction"},"content":{"raw":"<div class=\"introduction\">\n\nThe Collection interface defines an iterator method that returns an object that implements the <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/util\/Iterator.html\">Iterator interface<\/a>, which is shown in the class diagram below.\n<table class=\"grid aligncenter\" style=\"border-collapse: collapse;width: 32.0695%;height: 137px\" border=\"0\">\n<tbody>\n<tr>\n<td style=\"width: 100%\"><code>&lt;&lt;Interface&gt;&gt; Iterator&lt;E&gt;<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 100%\"><code>hasNext():boolean<\/code>\n\n<code>next():E<\/code>\n\n<code>remove()<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\nAn Iterator object serves two functions: (a) a way to iterate over all the objects in a collection without having to know how\u00a0 they are stored in the collection. (b) a way to remove items from a collection while you are iterating over it. Any data structure that implements an Iterator can be manipulated using the same interface.\u00a0 Iterators are often more efficient than directly accessing elements as well.\n\n<\/div>","rendered":"<div class=\"introduction\">\n<p>The Collection interface defines an iterator method that returns an object that implements the <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/util\/Iterator.html\">Iterator interface<\/a>, which is shown in the class diagram below.<\/p>\n<table class=\"grid aligncenter\" style=\"border-collapse: collapse;width: 32.0695%;height: 137px\">\n<tbody>\n<tr>\n<td style=\"width: 100%\"><code>&lt;&lt;Interface&gt;&gt; Iterator&lt;E&gt;<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 100%\"><code>hasNext():boolean<\/code><\/p>\n<p><code>next():E<\/code><\/p>\n<p><code>remove()<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>An Iterator object serves two functions: (a) a way to iterate over all the objects in a collection without having to know how\u00a0 they are stored in the collection. (b) a way to remove items from a collection while you are iterating over it. Any data structure that implements an Iterator can be manipulated using the same interface.\u00a0 Iterators are often more efficient than directly accessing elements as well.<\/p>\n<\/div>\n","protected":false},"author":1,"menu_order":1,"template":"","meta":{"pb_show_title":"","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"chapter-type":[49],"contributor":[],"license":[],"class_list":["post-208","chapter","type-chapter","status-publish","hentry","chapter-type-numberless"],"part":207,"_links":{"self":[{"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/pressbooks\/v2\/chapters\/208","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":1,"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/pressbooks\/v2\/chapters\/208\/revisions"}],"predecessor-version":[{"id":209,"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/pressbooks\/v2\/chapters\/208\/revisions\/209"}],"part":[{"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/pressbooks\/v2\/parts\/207"}],"metadata":[{"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/pressbooks\/v2\/chapters\/208\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/wp\/v2\/media?parent=208"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/pressbooks\/v2\/chapter-type?post=208"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/wp\/v2\/contributor?post=208"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/libraryresources.nse.org.ng\/computersciencetwo\/wp-json\/wp\/v2\/license?post=208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}