{"id":419,"date":"2022-09-22T20:29:30","date_gmt":"2022-10-06T05:48:20","guid":{"rendered":"https:\/\/www.silicloud.com\/ja\/blog\/index.php\/2023\/11\/30\/java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8biterator%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3\/"},"modified":"2025-07-31T23:26:43","modified_gmt":"2025-07-31T14:26:43","slug":"java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8biterator%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8biterator%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3\/","title":{"rendered":"Java\u306b\u304a\u3051\u308bIterator\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3"},"content":{"rendered":"<p>\u30a4\u30c6\u30ec\u30fc\u30bf\u30fc\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u306f\u3001\u884c\u52d5\u30d1\u30bf\u30fc\u30f3\u306e\u3072\u3068\u3064\u3067\u3059\u3002\u30a4\u30c6\u30ec\u30fc\u30bf\u30fc\u30d1\u30bf\u30fc\u30f3\u306f\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30b0\u30eb\u30fc\u30d7\u3092\u30c8\u30e9\u30d0\u30fc\u30b9\u3059\u308b\u305f\u3081\u306e\u6a19\u6e96\u7684\u306a\u65b9\u6cd5\u3092\u63d0\u4f9b\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002\u30a4\u30c6\u30ec\u30fc\u30bf\u30fc\u30d1\u30bf\u30fc\u30f3\u306f\u3001Java\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u5e83\u304f\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u30a4\u30c6\u30ec\u30fc\u30bf\u30fc\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306f\u3001\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u30c8\u30e9\u30d0\u30fc\u30b9\u3059\u308b\u305f\u3081\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30a4\u30c6\u30ec\u30fc\u30bf\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3<\/h2>\n<p>GoF\u306b\u3088\u308b\u3068\u3001\u30a4\u30c6\u30ec\u30fc\u30bf\u30fc\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u306e\u76ee\u7684\u306f\u6b21\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<blockquote><p>\u4e0b\u5c64\u306e\u8868\u73fe\u3092\u516c\u958b\u305b\u305a\u306b\u3001\u96c6\u7d04\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u8981\u7d20\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u65b9\u6cd5\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p><\/blockquote>\n<p>\u30a4\u30c6\u30ec\u30fc\u30bf\u30d1\u30bf\u30fc\u30f3\u306f\u3001\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u9032\u884c\u3059\u308b\u3060\u3051\u3067\u306a\u304f\u3001\u8981\u4ef6\u306b\u57fa\u3065\u3044\u305f\u7570\u306a\u308b\u7a2e\u985e\u306e\u30a4\u30c6\u30ec\u30fc\u30bf\u3092\u63d0\u4f9b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30a4\u30c6\u30ec\u30fc\u30bf\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u306f\u3001\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u9032\u884c\u3059\u308b\u305f\u3081\u306e\u5b9f\u969b\u306e\u5b9f\u88c5\u3092\u96a0\u3057\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u5358\u306b\u30a4\u30c6\u30ec\u30fc\u30bf\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<h3>\u30a4\u30c6\u30ec\u30fc\u30bf\u30fc\u30d1\u30bf\u30fc\u30f3\u306e\u4f8b\u3002<\/h3>\n<p>\u30b7\u30f3\u30d7\u30eb\u306a\u4f8b\u3067\u30a4\u30c6\u30ec\u30fc\u30bf\u30fc\u30d1\u30bf\u30fc\u30f3\u3092\u7406\u89e3\u3057\u307e\u3057\u3087\u3046\u3002\u30e9\u30b8\u30aa\u30c1\u30e3\u30f3\u30cd\u30eb\u306e\u30ea\u30b9\u30c8\u304c\u3042\u308a\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30d7\u30ed\u30b0\u30e9\u30e0\u304c\u305d\u308c\u3089\u3092\u4e00\u3064\u305a\u3064\u307e\u305f\u306f\u30c1\u30e3\u30f3\u30cd\u30eb\u306e\u7a2e\u985e\u306b\u57fa\u3065\u3044\u3066\u30c8\u30e9\u30d0\u30fc\u30b9\u3057\u305f\u3044\u5834\u5408\u3092\u8003\u3048\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u4f8b\u3048\u3070\u3001\u4e00\u90e8\u306e\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u82f1\u8a9e\u306e\u30c1\u30e3\u30f3\u30cd\u30eb\u306b\u306e\u307f\u8208\u5473\u304c\u3042\u308a\u3001\u305d\u308c\u3089\u306e\u307f\u51e6\u7406\u3057\u305f\u3044\u3068\u3057\u307e\u3059\u3002\u4ed6\u306e\u7a2e\u985e\u306e\u30c1\u30e3\u30f3\u30cd\u30eb\u306f\u51e6\u7406\u3057\u305f\u304f\u3042\u308a\u307e\u305b\u3093\u3002\u3057\u305f\u304c\u3063\u3066\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306b\u30c1\u30e3\u30f3\u30cd\u30eb\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u63d0\u4f9b\u3057\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u304c\u30c1\u30e3\u30f3\u30cd\u30eb\u3092\u30c8\u30e9\u30d0\u30fc\u30b9\u3057\u3001\u51e6\u7406\u3059\u308b\u304b\u3069\u3046\u304b\u3092\u6c7a\u5b9a\u3059\u308b\u30ed\u30b8\u30c3\u30af\u3092\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3057\u304b\u3057\u3001\u3053\u306e\u89e3\u6c7a\u7b56\u306b\u306f\u591a\u304f\u306e\u554f\u984c\u304c\u3042\u308a\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u304c\u30c8\u30e9\u30d0\u30fc\u30b9\u306e\u305f\u3081\u306e\u30ed\u30b8\u30c3\u30af\u3092\u8003\u3048\u51fa\u3055\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u305f\u3081\u3001\u305d\u306e\u30ed\u30b8\u30c3\u30af\u304c\u6b63\u3057\u3044\u304b\u3069\u3046\u304b\u3092\u4fdd\u8a3c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002\u3055\u3089\u306b\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306e\u6570\u304c\u5897\u3048\u308b\u3068\u3001\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u304c\u975e\u5e38\u306b\u56f0\u96e3\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u3053\u3067\u3001\u30a4\u30c6\u30ec\u30fc\u30bf\u30fc\u30d1\u30bf\u30fc\u30f3\u3092\u4f7f\u7528\u3057\u3001\u30c1\u30e3\u30f3\u30cd\u30eb\u306e\u7a2e\u985e\u306b\u57fa\u3065\u3044\u305f\u53cd\u5fa9\u3092\u63d0\u4f9b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30d7\u30ed\u30b0\u30e9\u30e0\u304c\u30c1\u30e3\u30f3\u30cd\u30eb\u306e\u30ea\u30b9\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u306e\u306f\u30a4\u30c6\u30ec\u30fc\u30bf\u30fc\u3092\u901a\u3057\u3066\u306e\u307f\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u5b9f\u88c5\u306e\u6700\u521d\u306e\u90e8\u5206\u306f\u3001\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u304a\u3088\u3073\u30a4\u30c6\u30ec\u30fc\u30bf\u30fc\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306e\u5951\u7d04\u3092\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u3067\u3059\u3002ChannelTypeEnum.java<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.design.iterator;\r\n\r\npublic enum ChannelTypeEnum {\r\n\r\n\tENGLISH, HINDI, FRENCH, ALL;\r\n}\r\n<\/code><\/pre>\n<p>ChannelTypeEnum\u306f\u3001\u3055\u307e\u3056\u307e\u306a\u7a2e\u985e\u306e\u30c1\u30e3\u30f3\u30cd\u30eb\u3092\u5b9a\u7fa9\u3059\u308bJava\u306e\u5217\u6319\u578b\u3067\u3059\u3002Channel.java<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.design.iterator;\r\n\r\npublic class Channel {\r\n\r\n\tprivate double frequency;\r\n\tprivate ChannelTypeEnum TYPE;\r\n\t\r\n\tpublic Channel(double freq, ChannelTypeEnum type){\r\n\t\tthis.frequency=freq;\r\n\t\tthis.TYPE=type;\r\n\t}\r\n\r\n\tpublic double getFrequency() {\r\n\t\treturn frequency;\r\n\t}\r\n\r\n\tpublic ChannelTypeEnum getTYPE() {\r\n\t\treturn TYPE;\r\n\t}\r\n\t\r\n\t@Override\r\n\tpublic String toString(){\r\n\t\treturn \"Frequency=\"+this.frequency+\", Type=\"+this.TYPE;\r\n\t}\r\n\t\r\n}\r\n<\/code><\/pre>\n<p>Channel\u306f\u3001frequency\u3068channel type\u3068\u3044\u3046\u5c5e\u6027\u3092\u6301\u3064\u30b7\u30f3\u30d7\u30eb\u306aPOJO\u30af\u30e9\u30b9\u3067\u3059\u3002ChannelCollection.java<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.design.iterator;\r\n\r\npublic interface ChannelCollection {\r\n\r\n\tpublic void addChannel(Channel c);\r\n\t\r\n\tpublic void removeChannel(Channel c);\r\n\t\r\n\tpublic ChannelIterator iterator(ChannelTypeEnum type);\r\n\t\r\n}\r\n<\/code><\/pre>\n<p>ChannelCollection\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306f\u3001\u79c1\u305f\u3061\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u30af\u30e9\u30b9\u306e\u5b9f\u88c5\u306e\u5951\u7d04\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\u3002\u30c1\u30e3\u30f3\u30cd\u30eb\u3092\u8ffd\u52a0\u30fb\u524a\u9664\u3059\u308b\u305f\u3081\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u30c1\u30e3\u30f3\u30cd\u30eb\u306e\u30ea\u30b9\u30c8\u3092\u8fd4\u3059\u30e1\u30bd\u30c3\u30c9\u306f\u3042\u308a\u307e\u305b\u3093\u3002ChannelCollection\u306b\u306f\u3001\u8d70\u67fb\u306e\u305f\u3081\u306e\u30a4\u30c6\u30ec\u30fc\u30bf\u3092\u8fd4\u3059\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u308a\u307e\u3059\u3002ChannelIterator\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306f\u3001\u4ee5\u4e0b\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\uff1bChannelIterator.java<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.design.iterator;\r\n\r\npublic interface ChannelIterator {\r\n\r\n\tpublic boolean hasNext();\r\n\t\r\n\tpublic Channel next();\r\n}\r\n<\/code><\/pre>\n<p>\u4eca\u3001\u79c1\u305f\u3061\u306e\u30d9\u30fc\u30b9\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3068\u30b3\u30a2\u30af\u30e9\u30b9\u304c\u6e96\u5099\u3067\u304d\u307e\u3057\u305f\u306e\u3067\u3001\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u30af\u30e9\u30b9\u3068\u30a4\u30c6\u30ec\u30fc\u30bf\u306e\u5b9f\u88c5\u306b\u9032\u307f\u307e\u3057\u3087\u3046\u3002ChannelCollectionImpl.java<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.design.iterator;\r\n\r\nimport java.util.ArrayList;\r\nimport java.util.List;\r\n\r\npublic class ChannelCollectionImpl implements ChannelCollection {\r\n\r\n\tprivate List&lt;Channel&gt; channelsList;\r\n\r\n\tpublic ChannelCollectionImpl() {\r\n\t\tchannelsList = new ArrayList&lt;&gt;();\r\n\t}\r\n\r\n\tpublic void addChannel(Channel c) {\r\n\t\tthis.channelsList.add(c);\r\n\t}\r\n\r\n\tpublic void removeChannel(Channel c) {\r\n\t\tthis.channelsList.remove(c);\r\n\t}\r\n\r\n\t@Override\r\n\tpublic ChannelIterator iterator(ChannelTypeEnum type) {\r\n\t\treturn new ChannelIteratorImpl(type, this.channelsList);\r\n\t}\r\n\r\n\tprivate class ChannelIteratorImpl implements ChannelIterator {\r\n\r\n\t\tprivate ChannelTypeEnum type;\r\n\t\tprivate List&lt;Channel&gt; channels;\r\n\t\tprivate int position;\r\n\r\n\t\tpublic ChannelIteratorImpl(ChannelTypeEnum ty,\r\n\t\t\t\tList&lt;Channel&gt; channelsList) {\r\n\t\t\tthis.type = ty;\r\n\t\t\tthis.channels = channelsList;\r\n\t\t}\r\n\r\n\t\t@Override\r\n\t\tpublic boolean hasNext() {\r\n\t\t\twhile (position &lt; channels.size()) {\r\n\t\t\t\tChannel c = channels.get(position);\r\n\t\t\t\tif (c.getTYPE().equals(type) || type.equals(ChannelTypeEnum.ALL)) {\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t} else\r\n\t\t\t\t\tposition++;\r\n\t\t\t}\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\t@Override\r\n\t\tpublic Channel next() {\r\n\t\t\tChannel c = channels.get(position);\r\n\t\t\tposition++;\r\n\t\t\treturn c;\r\n\t\t}\r\n\r\n\t}\r\n}\r\n<\/code><\/pre>\n<p>\u30a4\u30c6\u30ec\u30fc\u30bf\u30fc\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306e\u5185\u90e8\u30af\u30e9\u30b9\u5b9f\u88c5\u306b\u6ce8\u76ee\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u3053\u306e\u5b9f\u88c5\u306f\u4ed6\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306b\u4f7f\u7528\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u30af\u30e9\u30b9\u3082\u540c\u69d8\u306e\u30a2\u30d7\u30ed\u30fc\u30c1\u3092\u63a1\u7528\u3057\u3066\u304a\u308a\u3001\u3059\u3079\u3066\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u30af\u30e9\u30b9\u306b\u306f\u30a4\u30c6\u30ec\u30fc\u30bf\u30fc\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306e\u5185\u90e8\u30af\u30e9\u30b9\u5b9f\u88c5\u304c\u3042\u308a\u307e\u3059\u3002\u79c1\u305f\u3061\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3068\u30a4\u30c6\u30ec\u30fc\u30bf\u30fc\u3092\u4f7f\u7528\u3057\u3066\u3001\u30c1\u30e3\u30cd\u30eb\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u8d70\u67fb\u3059\u308b\u305f\u3081\u306e\u30b7\u30f3\u30d7\u30eb\u306a\u30a4\u30c6\u30ec\u30fc\u30bf\u30fc\u30d1\u30bf\u30fc\u30f3\u306e\u30c6\u30b9\u30c8\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u3044\u3066\u307f\u307e\u3057\u3087\u3046\u3002IteratorPatternTest.java<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.design.iterator;\r\n\r\npublic class IteratorPatternTest {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tChannelCollection channels = populateChannels();\r\n\t\tChannelIterator baseIterator = channels.iterator(ChannelTypeEnum.ALL);\r\n\t\twhile (baseIterator.hasNext()) {\r\n\t\t\tChannel c = baseIterator.next();\r\n\t\t\tSystem.out.println(c.toString());\r\n\t\t}\r\n\t\tSystem.out.println(\"******\");\r\n\t\t\/\/ Channel Type Iterator\r\n\t\tChannelIterator englishIterator = channels.iterator(ChannelTypeEnum.ENGLISH);\r\n\t\twhile (englishIterator.hasNext()) {\r\n\t\t\tChannel c = englishIterator.next();\r\n\t\t\tSystem.out.println(c.toString());\r\n\t\t}\r\n\t}\r\n\r\n\tprivate static ChannelCollection populateChannels() {\r\n\t\tChannelCollection channels = new ChannelCollectionImpl();\r\n\t\tchannels.addChannel(new Channel(98.5, ChannelTypeEnum.ENGLISH));\r\n\t\tchannels.addChannel(new Channel(99.5, ChannelTypeEnum.HINDI));\r\n\t\tchannels.addChannel(new Channel(100.5, ChannelTypeEnum.FRENCH));\r\n\t\tchannels.addChannel(new Channel(101.5, ChannelTypeEnum.ENGLISH));\r\n\t\tchannels.addChannel(new Channel(102.5, ChannelTypeEnum.HINDI));\r\n\t\tchannels.addChannel(new Channel(103.5, ChannelTypeEnum.FRENCH));\r\n\t\tchannels.addChannel(new Channel(104.5, ChannelTypeEnum.ENGLISH));\r\n\t\tchannels.addChannel(new Channel(105.5, ChannelTypeEnum.HINDI));\r\n\t\tchannels.addChannel(new Channel(106.5, ChannelTypeEnum.FRENCH));\r\n\t\treturn channels;\r\n\t}\r\n\r\n}\r\n<\/code><\/pre>\n<p>\u4e0a\u8a18\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u51fa\u529b\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>Frequency=98.5, Type=ENGLISH\r\nFrequency=99.5, Type=HINDI\r\nFrequency=100.5, Type=FRENCH\r\nFrequency=101.5, Type=ENGLISH\r\nFrequency=102.5, Type=HINDI\r\nFrequency=103.5, Type=FRENCH\r\nFrequency=104.5, Type=ENGLISH\r\nFrequency=105.5, Type=HINDI\r\nFrequency=106.5, Type=FRENCH\r\n******\r\nFrequency=98.5, Type=ENGLISH\r\nFrequency=101.5, Type=ENGLISH\r\nFrequency=104.5, Type=ENGLISH\r\n<\/code><\/pre>\n<h3>\u30a4\u30c6\u30ec\u30fc\u30bf\u30fc\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u306e\u91cd\u8981\u306a\u30dd\u30a4\u30f3\u30c8<\/h3>\n<ul class=\"post-ul\">\n<li>Iterator pattern is useful when you want to provide a standard way to iterate over a collection and hide the implementation logic from client program.<\/li>\n<li>The logic for iteration is embedded in the collection itself and it helps client program to iterate over them easily.<\/li>\n<\/ul>\n<h3>JDK\u306b\u304a\u3051\u308b\u30a4\u30c6\u30ec\u30fc\u30bf\u30fc\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3<\/h3>\n<p>\u79c1\u305f\u3061\u306f\u307f\u3093\u306a\u3001Collection framework\u306eIterator\u304c\u30a4\u30c6\u30ec\u30fc\u30bf\u30fc\u30d1\u30bf\u30fc\u30f3\u306e\u5b9f\u88c5\u306e\u30d9\u30b9\u30c8\u306a\u4f8b\u3067\u3042\u308b\u3053\u3068\u3092\u77e5\u3063\u3066\u3044\u307e\u3059\u304c\u3001java.util.Scanner\u30af\u30e9\u30b9\u3082Iterator\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3092\u5b9f\u88c5\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u3054\u5b58\u3058\u3067\u3057\u3087\u3046\u304b\u3002Java Scanner\u30af\u30e9\u30b9\u306b\u3064\u3044\u3066\u306f\u3001\u3053\u306e\u6295\u7a3f\u3092\u8aad\u3093\u3067\u5b66\u3093\u3067\u304f\u3060\u3055\u3044\u3002\u30a4\u30c6\u30ec\u30fc\u30bf\u30fc\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u306b\u95a2\u3057\u3066\u306f\u4ee5\u4e0a\u3067\u3059\u3002\u5f79\u7acb\u3064\u304b\u3064\u7406\u89e3\u3057\u3084\u3059\u3044\u3053\u3068\u3092\u9858\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30a4\u30c6\u30ec\u30fc\u30bf\u30fc\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u306f\u3001\u884c\u52d5\u30d1\u30bf\u30fc\u30f3\u306e\u3072\u3068\u3064\u3067\u3059\u3002\u30a4\u30c6\u30ec\u30fc\u30bf\u30fc\u30d1\u30bf\u30fc\u30f3\u306f\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30b0\u30eb\u30fc\u30d7\u3092\u30c8\u30e9\u30d0\u30fc\u30b9\u3059\u308b\u305f\u3081\u306e\u6a19\u6e96\u7684\u306a\u65b9\u6cd5\u3092\u63d0\u4f9b\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002\u30a4\u30c6\u30ec\u30fc\u30bf\u30fc\u30d1\u30bf\u30fc\u30f3\u306f\u3001Java\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u30d5\u30ec\u30fc\u30e0 [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[26,61],"class_list":["post-419","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-26","tag-61"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Java\u306b\u304a\u3051\u308bIterator\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3 - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"Java\u306b\u304a\u3051\u308bIterator\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/ja\/blog\/java\u306b\u304a\u3051\u308biterator\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\/\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java\u306b\u304a\u3051\u308bIterator\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\" \/>\n<meta property=\"og:description\" content=\"Java\u306b\u304a\u3051\u308bIterator\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/ja\/blog\/java\u306b\u304a\u3051\u308biterator\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2022-10-06T05:48:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-31T14:26:43+00:00\" \/>\n<meta name=\"author\" content=\"\u84ee, \u7ffc\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u57f7\u7b46\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u84ee, \u7ffc\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"15\u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8biterator%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3\/\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8biterator%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3\/\",\"name\":\"Java\u306b\u304a\u3051\u308bIterator\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\"},\"datePublished\":\"2022-10-06T05:48:20+00:00\",\"dateModified\":\"2025-07-31T14:26:43+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/cdc124a0aaebf26393d8d591183ca413\"},\"description\":\"Java\u306b\u304a\u3051\u308bIterator\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8biterator%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3\/#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8biterator%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8biterator%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/ja\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\u306b\u304a\u3051\u308bIterator\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"ja\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/cdc124a0aaebf26393d8d591183ca413\",\"name\":\"\u84ee, \u7ffc\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/27308f733c7fcdac8617926a0100c77213339c4e501310a08c0baf946bf823bc?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/27308f733c7fcdac8617926a0100c77213339c4e501310a08c0baf946bf823bc?s=96&d=mm&r=g\",\"caption\":\"\u84ee, \u7ffc\"},\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/author\/rentsubasa\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8biterator%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Java\u306b\u304a\u3051\u308bIterator\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3 - Blog - Silicon Cloud","description":"Java\u306b\u304a\u3051\u308bIterator\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002","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:\/\/www.silicloud.com\/ja\/blog\/java\u306b\u304a\u3051\u308biterator\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\/","og_locale":"ja_JP","og_type":"article","og_title":"Java\u306b\u304a\u3051\u308bIterator\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","og_description":"Java\u306b\u304a\u3051\u308bIterator\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002","og_url":"https:\/\/www.silicloud.com\/ja\/blog\/java\u306b\u304a\u3051\u308biterator\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2022-10-06T05:48:20+00:00","article_modified_time":"2025-07-31T14:26:43+00:00","author":"\u84ee, \u7ffc","twitter_card":"summary_large_image","twitter_misc":{"\u57f7\u7b46\u8005":"\u84ee, \u7ffc","\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593":"15\u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8biterator%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3\/","url":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8biterator%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3\/","name":"Java\u306b\u304a\u3051\u308bIterator\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website"},"datePublished":"2022-10-06T05:48:20+00:00","dateModified":"2025-07-31T14:26:43+00:00","author":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/cdc124a0aaebf26393d8d591183ca413"},"description":"Java\u306b\u304a\u3051\u308bIterator\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3002\u5b9f\u8df5\u7684\u306a\u4f8b\u3068\u30b3\u30fc\u30c9\u3001\u6ce8\u610f\u70b9\u3092\u542b\u3081\u3066\u521d\u5fc3\u8005\u306b\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u8aac\u660e\u3057\u307e\u3059\u3002","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8biterator%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3\/#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8biterator%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8biterator%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/ja\/blog\/"},{"@type":"ListItem","position":2,"name":"Java\u306b\u304a\u3051\u308bIterator\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website","url":"https:\/\/www.silicloud.com\/ja\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"ja"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/cdc124a0aaebf26393d8d591183ca413","name":"\u84ee, \u7ffc","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/27308f733c7fcdac8617926a0100c77213339c4e501310a08c0baf946bf823bc?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/27308f733c7fcdac8617926a0100c77213339c4e501310a08c0baf946bf823bc?s=96&d=mm&r=g","caption":"\u84ee, \u7ffc"},"url":"https:\/\/www.silicloud.com\/ja\/blog\/author\/rentsubasa\/"},{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/java%e3%81%ab%e3%81%8a%e3%81%91%e3%82%8biterator%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/419","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/comments?post=419"}],"version-history":[{"count":1,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/419\/revisions"}],"predecessor-version":[{"id":40365,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/419\/revisions\/40365"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/media?parent=419"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/categories?post=419"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/tags?post=419"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}