{"id":2600,"date":"2018-05-09T23:58:20","date_gmt":"2018-05-09T14:58:20","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=2600"},"modified":"2023-04-17T22:16:55","modified_gmt":"2023-04-17T13:16:55","slug":"%e3%80%90java%e3%80%91arraylist%e3%81%a7%e8%a6%81%e7%b4%a0%e3%82%92%e9%a0%86%e3%81%ab%e5%8f%96%e3%82%8a%e5%87%ba%e3%81%993%e3%81%a4%e3%81%ae%e6%96%b9%e6%b3%95%e3%81%ae%e9%81%95%e3%81%84","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=2600","title":{"rendered":"\u3010Java\u3011ArrayList\u3067\u8981\u7d20\u3092\u9806\u306b\u53d6\u308a\u51fa\u30594\u3064\u306e\u65b9\u6cd5\u306e\u9055\u3044(\u62e1\u5f35for\u6587\u3001\u30a4\u30c6\u30ec\u30fc\u30bf\u3001\u30e9\u30e0\u30c0\u5f0f\u7b49\uff09"},"content":{"rendered":"<p>ArrayList\u306e\u8981\u7d20\u3092\u9806\u306b\u53d6\u308a\u51fa\u3059\u65b9\u6cd5\u3068\u3057\u3066\u306f\u3001\u4e0b\u8a18\u306e\u56db\u3064\u306e\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>for\u6587\u3092\u7528\u3044\u305f\u8981\u7d20\u306e\u53d6\u308a\u51fa\u3057<\/li>\n<li>\u62e1\u5f35for\u6587\u3092\u7528\u3044\u305f\u8981\u7d20\u306e\u53d6\u308a\u51fa\u3057<\/li>\n<li>\u30a4\u30c6\u30ec\u30fc\u30bf\u3092\u4f7f\u3063\u305f\u8981\u7d20\u306e\u53d6\u308a\u51fa\u3057<\/li>\n<li>\u30e9\u30e0\u30c0\u5f0f\u3001StreamAPI\u3092\u4f7f\u3063\u305f\u8981\u7d20\u306e\u53d6\u308a\u51fa\u3057<\/li>\n<\/ul>\n<h2>for\u6587<\/h2>\n<p>\u30ea\u30b9\u30c8\u306e\u30b5\u30a4\u30ba\u6587\u3060\u3051\u3001for\u6587\u3067\u30eb\u30fc\u30d7\u3092\u307e\u308f\u3057\u3066\u30ab\u30a6\u30f3\u30c8\u30a2\u30c3\u30d7\u3055\u305b\u308b\u3084\u308a\u65b9\u3067\u3059\u306d\u3002<\/p>\n<p>\u5c11\u3057\u3084\u3084\u3053\u3057\u3044\u3067\u3059\u304c\u3001<span style=\"color: #ff0000;\"><strong>Java\u306e\u57fa\u672c\u6587\u6cd5\u3057\u304b\u4f7f\u3063\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u521d\u5fc3\u8005\u306b\u3067\u3082\u76f4\u611f\u7684\u306b\u7406\u89e3\u306f\u3067\u304d\u305d\u3046\u3067\u3059\u3057\u3001\u53e4\u3044Java\u3067\u3082\u5bfe\u5fdc\u3057\u3066\u3044\u307e\u3059\u3002<\/strong><\/span><\/p>\n<pre class=\"lang:default decode:true\">public class Main {\r\n\r\n\tpublic static void main(String args[]) {\r\n\r\n\t\tArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();\r\n\t\tlist.add(\"test\");\r\n\t\tlist.add(\"test1\");\r\n\r\n\t\tfor(int i=0;i&lt;list.size();i++) {\r\n\t\t\tSystem.out.println(list.get(i));\r\n\t\t}\r\n\r\n\t}\r\n\r\n}<\/pre>\n<h2>\u62e1\u5f35for\u6587<\/h2>\n<p>\u666e\u901a\u306efor\u6587\u306b\u6bd4\u3079\u308b\u3068\u3001\u62e1\u5f35for\u6587\u306f<span style=\"color: #ff0000;\"><strong>\u975e\u5e38\u306b\u3059\u3063\u304d\u308a\u3057\u305f\u5f62<\/strong><\/span>\u306b\u306a\u308a\u307e\u3057\u305f\u3002\uff08\u307b\u307c\u5927\u4e08\u592b\u304b\u3068\u601d\u3044\u307e\u3059\u304c\u3001Java5\u4ee5\u964d\u3057\u304b\u4f7f\u3048\u306a\u3044\u3067\u3059\u3002\uff09<\/p>\n<pre class=\"lang:default decode:true\">public class Main {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();\r\n\t\tlist.add(\"test\");\r\n\t\tlist.add(\"test1\");\r\n\r\n\t\tfor(String li:list) {\r\n\t\t\tSystem.out.println(li);\r\n\t\t}\r\n\t}\r\n}<\/pre>\n<h2>\u30a4\u30c6\u30ec\u30fc\u30bf<\/h2>\n<p>\u30a4\u30c6\u30ec\u30fc\u30bf\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u300c\u30ea\u30b9\u30c8\u306e\u4e2d\u8eab\u3092\u9806\u306b\u53d6\u308a\u51fa\u3059\u5c02\u7528\u9053\u5177\u300d<\/strong><\/span>\u306e\u3088\u3046\u306a\u30a4\u30e1\u30fc\u30b8\u3067\u3059\u3002\u77e2\u5370\u3067\u30ea\u30b9\u30c8\u306b\u542b\u307e\u308c\u3066\u3044\u308b\u8981\u7d20\u3092\u3001\u79fb\u52d5\u3057\u3066\u3044\u304f\u611f\u3058\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">public class Main {\r\n\r\n\tpublic static void main(String args[]) {\r\n\r\n\t\tArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();\r\n\t\tlist.add(\"test\");\r\n\t\tlist.add(\"test1\");\r\n\r\n\t\tIterator&lt;String&gt; it = list.iterator();\r\n\r\n\t\twhile(it.hasNext()) {\r\n\t\t\tSystem.out.println(it.next());\r\n\t\t}\r\n\r\n\t}\r\n\r\n}<\/pre>\n<p>\u30a4\u30c6\u30ec\u30fc\u30bf\u3092\u4f7f\u3046\u306b\u306f\u3001\u307e\u305a\u306f\u3001\u300cIteratotr&lt;\u578b&gt; \u5909\u6570\u540d = ArrayList.iterator()\u300d\u3068\u3044\u3046\u5f62\u3067\u3001<span style=\"color: #ff0000;\"><strong>\u30ea\u30b9\u30c8\u306e\u6700\u521d\u306e\u8981\u7d20\u3092\u6307\u3057\u305f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/strong><\/span>\uff08new\u306f\u5fc5\u8981\u306a\u3044\u3067\u3059\u3002\uff09<\/p>\n<p>\u305d\u306e\u5f8c\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u300chasNext\u300d\u306b\u3088\u3063\u3066\u3001\u9806\u756a\u306b\u30ea\u30b9\u30c8\u306e\u4e2d\u3092\u79fb\u52d5<\/strong><\/span>\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h2>\u30e9\u30e0\u30c0\u5f0f\u3001StreamAPI<\/h2>\n<pre class=\"lang:default decode:true\">public class Main {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();\r\n\t\tlist.add(\"test\");\r\n\t\tlist.add(\"test1\");\r\n\r\n\t\tlist.stream().forEach(li -&gt; System.out.println(li));\r\n\r\n\t}\r\n}<\/pre>\n<p>\u30e9\u30e0\u30c0\u5f0f\u3084\u3001StreamAPI\u3060\u3068\u3001<span style=\"color: #ff0000;\"><strong>\u975e\u5e38\u306b\u30b7\u30f3\u30d7\u30eb\u306a\u5f62\u3067\u8a18\u8ff0\u3067\u304d\u307e\u3059\u3088\u306d\u3002\u305f\u3060\u3001\u305d\u308c\u3068\u540c\u6642\u306b\u975e\u5e38\u306b\u7406\u89e3\u3057\u3065\u3089\u3044\u3067\u3059\u3002<\/strong><\/span><\/p>\n<p>\u8a73\u3057\u304f\u306f\u3001\u4e0b\u8a18\u306e\u8a18\u4e8b\u3067\u89e3\u8aac\u3057\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u3042\u308f\u305b\u3066\u3054\u89a7\u306b\u306a\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"s3dRYESBIV\"><p><a href=\"http:\/\/www.code-magagine.com\/?p=2145\">\u3010Java\u3011Java\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u306a\u3089\u77e5\u3089\u306a\u3044\u3068\u4eca\u5f8c\u304c\u5371\u3046\u3044\uff01\uff1f\u30e9\u30e0\u30c0\u5f0f\u3092\u308f\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac(Java8\u4ee5\u964d\uff09<\/a><\/p><\/blockquote>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"http:\/\/www.code-magagine.com\/?p=2145&#038;embed=true#?secret=s3dRYESBIV\" data-secret=\"s3dRYESBIV\" width=\"500\" height=\"282\" title=\"&#8220;\u3010Java\u3011Java\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u306a\u3089\u77e5\u3089\u306a\u3044\u3068\u4eca\u5f8c\u304c\u5371\u3046\u3044\uff01\uff1f\u30e9\u30e0\u30c0\u5f0f\u3092\u308f\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac(Java8\u4ee5\u964d\uff09&#8221; &#8212; \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30de\u30ac\u30b8\u30f3\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<h2>\u5404\u53d6\u308a\u51fa\u3057\u65b9\u306e\u30e1\u30ea\u30c3\u30c8\u3001\u30c7\u30e1\u30ea\u30c3\u30c8\u6bd4\u8f03<\/h2>\n<table>\n<tbody>\n<tr>\n<th>\u8981\u7d20\u306e\u53d6\u308a\u51fa\u3057\u65b9<\/th>\n<th>\u30e1\u30ea\u30c3\u30c8<\/th>\n<th>\u30c7\u30e1\u30ea\u30c3\u30c8<\/th>\n<\/tr>\n<tr>\n<td>for\u6587<\/td>\n<td>Java1.4\u4ee5\u4e0b\u3067\u3082\u5229\u7528\u53ef\u80fd<\/td>\n<td>\u69cb\u6587\u304c\u5c11\u3057\u308f\u304b\u308a\u306b\u304f\u3044<\/td>\n<\/tr>\n<tr>\n<td>\u62e1\u5f35for\u6587<\/td>\n<td>\u308f\u304b\u308a\u3084\u3059\u3044<\/p>\n<p>HashSet\u7b49\u3067\u3082\u5229\u7528\u53ef\u80fd<\/td>\n<td>Java5\u4ee5\u964d\u3067\u306a\u3044\u3068\u4f7f\u3048\u306a\u3044\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u30a4\u30c6\u30ec\u30fc\u30bf<\/td>\n<td>Java1.4\u4ee5\u4e0b\u3067\u3082\u5229\u7528\u53ef\u80fd<\/p>\n<p>HashSet\u3082\u5229\u7528\u53ef\u80fd<\/td>\n<td>\u69cb\u6587\u304c\u308f\u304b\u308a\u306b\u304f\u3044<\/td>\n<\/tr>\n<tr>\n<td>\u30e9\u30e0\u30c0\u5f0f\u3001StreamAPI<\/td>\n<td>\u69cb\u6587\u304c\u77ed\u3044<\/p>\n<p>\u4e00\u756a\u672a\u6765\u304c\u3042\u308b\u3002<\/td>\n<td>\u30e9\u30e0\u30c0\u5f0f\u3084StreamAPI\u306e\u7406\u89e3\u304c\u5fc5\u8981<\/p>\n<p>Java8\u4ee5\u964d\u3067\u306a\u3044\u3068\u4f7f\u3048\u306a\u3044\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7dcf\u5408\u7684\u306b\u898b\u308b\u3068\u3001<span style=\"color: #ff0000;\"><strong>\u73fe\u6642\u70b9\u3067\u306f\u3001\u30d0\u30e9\u30f3\u30b9\u306e\u3044\u3044\u300c\u62e1\u5f35for\u6587\u300d\u304c\u4e00\u756a\u512a\u308c\u3066\u3044\u308b<\/strong><\/span>\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002\u5b9f\u969b\u306b\u958b\u767a\u73fe\u5834\u3067\u4e00\u756a\u3088\u304f\u898b\u304b\u3051\u307e\u3059\u3002<\/p>\n<p>\u6b21\u70b9\u3067\u3001<span style=\"color: #ff0000;\"><strong>\u300c\u30e9\u30e0\u30c0\u5f0f\u3001StreamAPI\u300d<\/strong><\/span>\u3092\u4f7f\u3063\u305f\u53d6\u308a\u51fa\u3057\u65b9\u3060\u3068\u601d\u3044\u307e\u3059\u3002\u4eca\u5f8c\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u3069\u3093\u3069\u3093StreamAPI\u304c\u4f7f\u3048\u308b\u524d\u63d0\u306eAPI\u304c\u5897\u3048\u3066\u3044\u304f\u3067\u3057\u3087\u3046\u3057\u3001\u6587\u3082\u30b7\u30f3\u30d7\u30eb\u306b\u66f8\u3051\u308b\u306e\u3067\u4eca\u5f8c\u306e\u4e3b\u6d41<\/strong><\/span>\u306b\u306a\u3063\u3066\u3044\u304d\u305d\u3046\u306a\u6c17\u304c\u3057\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"ArrayList\u306e\u8981\u7d20\u3092\u9806\u306b\u53d6\u308a\u51fa\u3059\u65b9\u6cd5\u3068\u3057\u3066\u306f\u3001\u4e0b\u8a18\u306e\u56db\u3064\u306e\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002 for\u6587\u3092\u7528\u3044\u305f\u8981\u7d20\u306e\u53d6\u308a\u51fa\u3057 \u62e1\u5f35for\u6587\u3092\u7528\u3044\u305f\u8981\u7d20\u306e\u53d6\u308a\u51fa\u3057 \u30a4\u30c6\u30ec\u30fc\u30bf\u3092\u4f7f\u3063\u305f\u8981\u7d20\u306e\u53d6\u308a\u51fa\u3057 \u30e9\u30e0\u30c0\u5f0f\u3001StreamAPI\u3092\u4f7f\u3063\u305f [&hellip;]","protected":false},"author":1,"featured_media":852,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/2600"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2600"}],"version-history":[{"count":10,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/2600\/revisions"}],"predecessor-version":[{"id":18869,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/2600\/revisions\/18869"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/media\/852"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2600"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2600"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2600"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}