{"id":38887,"date":"2024-11-26T14:33:39","date_gmt":"2024-11-26T06:33:39","guid":{"rendered":"https:\/\/fwq.ai\/blog\/38887\/"},"modified":"2024-11-26T14:33:39","modified_gmt":"2024-11-26T06:33:39","slug":"%e9%a1%b9%e7%9b%ae%e4%bb%85%e5%9c%a8%e7%89%b9%e6%ae%8a%e6%83%85%e5%86%b5%e4%b8%8b%e4%bd%bf%e7%94%a8%e4%be%8b%e5%a4%96","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/38887\/","title":{"rendered":"\u9879\u76ee\u4ec5\u5728\u7279\u6b8a\u60c5\u51b5\u4e0b\u4f7f\u7528\u4f8b\u5916"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173165698716204.jpg\" class=\"aligncenter\" title=\"\u9879\u76ee\u4ec5\u5728\u7279\u6b8a\u60c5\u51b5\u4e0b\u4f7f\u7528\u4f8b\u5916\u63d2\u56fe\" alt=\"\u9879\u76ee\u4ec5\u5728\u7279\u6b8a\u60c5\u51b5\u4e0b\u4f7f\u7528\u4f8b\u5916\u63d2\u56fe\" \/><\/p>\n<p><strong>\u907f\u514d\u4f7f\u7528\u5f02\u5e38\u8fdb\u884c\u5e38\u89c1\u7684\u6d41\u91cf\u63a7\u5236\uff1a<\/strong><\/p>\n<p>\u5f02\u5e38\u53ea\u80fd\u7528\u4e8e\u610f\u5916\u60c5\u51b5\uff0c\u800c\u4e0d\u662f\u7528\u6765\u63a7\u5236\u7a0b\u5e8f\u7684\u6d41\u7a0b\u3002<\/p>\n<p>\u6709\u95ee\u9898\u7684\u4ee3\u7801\u793a\u4f8b\uff1a\u5728\u8d85\u51fa\u6570\u7ec4\u7684\u9650\u5236\u65f6\u5c1d\u8bd5\u4f7f\u7528\u5f02\u5e38\u6765\u7ed3\u675f\u5faa\u73af\u3002<\/p>\n<pre>try {\n    int i = 0;\n    while (true) {\n        system.out.println(array[i++]);\n    }\n} catch (arrayindexoutofboundsexception e) {\n    \/\/ este c\u00f3digo encerra o loop quando o \u00edndice ultrapassa o tamanho do array\n}\n\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u95ee\u9898\uff1a\u8fd9\u79cd\u5f02\u5e38\u7684\u4f7f\u7528\u6548\u7387\u4f4e\u4e0b\u4e14\u4ee4\u4eba\u56f0\u60d1\u3002\u6700\u597d\u4f7f\u7528\u5408\u9002\u7684\u5faa\u73af\u7ed3\u6784\u3002<\/p>\n<pre>for (int i = 0; i &lt; array.length; i++) {\n    system.out.println(array[i]);\n}\n\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>api \u8bbe\u8ba1\u542b\u4e49\uff1a<\/strong><\/p>\n<p>\u8bbe\u8ba1\u826f\u597d\u7684 api \u5e94\u907f\u514d\u5728\u6b63\u5e38\u6d41\u7a0b\u4e2d\u5f3a\u5236\u4f7f\u7528\u5f02\u5e38\u3002<\/p>\n<p>\u793a\u4f8b\uff1aiterator\u63a5\u53e3\u63d0\u4f9b\u4e86hasnext()\u65b9\u6cd5\u6765\u68c0\u67e5\u662f\u5426\u6709\u66f4\u591a\u5143\u7d20\uff0c\u907f\u514d\u8c03\u7528next()\u65f6\u51fa\u73b0\u4e0d\u5fc5\u8981\u7684\u5f02\u5e38\u3002<\/p>\n<pre>Iterator&lt;String&gt; iterator = list.iterator();\nwhile (iterator.hasNext()) {\n    System.out.println(iterator.next());\n}\n\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u72b6\u6001\u76f8\u5173\u65b9\u6cd5\u7684\u66ff\u4ee3\u65b9\u6848\uff1a<\/p>\n<p>\u5f53\u65e0\u6cd5\u6ee1\u8db3\u9884\u671f\u72b6\u6001\u65f6\uff0c\u63d0\u4f9b\u5355\u72ec\u7684\u65b9\u6cd5\u6765\u6d4b\u8bd5\u72b6\u6001\uff08hasnext\uff09\u6216\u7279\u6b8a\u7684\u8fd4\u56de\u503c\uff0c\u4f8b\u5982 null \u6216optional\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u9879\u76ee\u4ec5\u5728\u7279\u6b8a\u60c5\u51b5\u4e0b\u4f7f\u7528\u4f8b\u5916\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u907f\u514d\u4f7f\u7528\u5f02\u5e38\u8fdb\u884c\u5e38\u89c1\u7684\u6d41\u91cf\u63a7\u5236\uff1a \u5f02\u5e38\u53ea\u80fd\u7528\u4e8e\u610f\u5916\u60c5\u51b5\uff0c\u800c\u4e0d\u662f\u7528\u6765\u63a7\u5236\u7a0b\u5e8f\u7684\u6d41\u7a0b\u3002 \u6709\u95ee\u9898\u7684\u4ee3\u7801\u793a\u4f8b\uff1a\u5728\u8d85\u51fa\u6570\u7ec4\u7684\u9650\u5236\u65f6\u5c1d\u8bd5\u4f7f\u7528\u5f02\u5e38\u6765\u7ed3\u675f\u5faa\u73af\u3002 try { int i = 0; while (true) { system.out.println(array[i++]); } } catch (arrayindexoutofboundsexception e) { \/\/ este c\u00f3digo encerra o loop quando o \u00edndice ultrapassa o tamanho do array } \u767b\u5f55\u540e\u590d\u5236 \u95ee\u9898\uff1a\u8fd9\u79cd\u5f02\u5e38\u7684\u4f7f\u7528\u6548\u7387\u4f4e\u4e0b\u4e14\u4ee4\u4eba\u56f0\u60d1\u3002\u6700\u597d\u4f7f\u7528\u5408\u9002\u7684\u5faa\u73af\u7ed3\u6784\u3002 for (int i = 0; i &lt; array.length; i++) { system.out.println(array[i]); } \u767b\u5f55\u540e\u590d\u5236 api \u8bbe\u8ba1\u542b\u4e49\uff1a \u8bbe\u8ba1\u826f\u597d\u7684 api \u5e94\u907f\u514d\u5728\u6b63\u5e38\u6d41\u7a0b\u4e2d\u5f3a\u5236\u4f7f\u7528\u5f02\u5e38\u3002 \u793a\u4f8b\uff1aiterator\u63a5\u53e3\u63d0\u4f9b\u4e86hasnext()\u65b9\u6cd5\u6765\u68c0\u67e5\u662f\u5426\u6709\u66f4\u591a\u5143\u7d20\uff0c\u907f\u514d\u8c03\u7528next()\u65f6\u51fa\u73b0\u4e0d\u5fc5\u8981\u7684\u5f02\u5e38\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-38887","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/38887","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=38887"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/38887\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=38887"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=38887"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=38887"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}