{"id":39389,"date":"2024-11-26T17:17:09","date_gmt":"2024-11-26T09:17:09","guid":{"rendered":"https:\/\/fwq.ai\/blog\/39389\/"},"modified":"2024-11-26T17:17:09","modified_gmt":"2024-11-26T09:17:09","slug":"java%e6%80%8e%e4%b9%88%e6%89%8b%e5%8a%a8%e8%be%93%e5%85%a5%e4%b8%80%e4%b8%b2%e6%95%b0%e7%bb%84","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/39389\/","title":{"rendered":"java\u600e\u4e48\u624b\u52a8\u8f93\u5165\u4e00\u4e32\u6570\u7ec4"},"content":{"rendered":"<blockquote><p>\n  \u5728 java \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u624b\u52a8\u8f93\u5165\u4e00\u4e32\u6570\u7ec4\uff1a\u5bfc\u5165 scanner \u7c7b\uff1aimport java.util.scanner;\u521b\u5efa scanner \u5bf9\u8c61\uff1ascanner scanner = new scanner(system.in);\u63d0\u793a\u7528\u6237\u8f93\u5165\uff1asystem.out.print(&#8220;\u8bf7\u8f93\u5165\u6570\u7ec4\u5143\u7d20\uff08\u4ee5\u7a7a\u683c\u5206\u9694\uff09\uff1a&#8221;);\u4f7f\u7528 nextline() \u8bfb\u53d6\u4e00\u884c\u8f93\u5165\uff1astring input = scanner.nextline();\u5c06\u8f93\u5165\u5b57\u7b26\u4e32\u62c6\u5206\u4e3a\u6570\u7ec4\uff1astring[] array = inpu\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/16\/2024111607095490236.jpg\" class=\"aligncenter\" title=\"java\u600e\u4e48\u624b\u52a8\u8f93\u5165\u4e00\u4e32\u6570\u7ec4\u63d2\u56fe\" alt=\"java\u600e\u4e48\u624b\u52a8\u8f93\u5165\u4e00\u4e32\u6570\u7ec4\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 Java \u4e2d\u624b\u52a8\u8f93\u5165\u4e00\u4e32\u6570\u7ec4<\/strong><\/p>\n<p><strong>\u56de\u7b54\uff1a<\/strong><\/p>\n<p>\u5728 Java \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 Scanner \u7c7b\u6765\u624b\u52a8\u4ece\u63a7\u5236\u53f0\u8f93\u5165\u4e00\u4e32\u6570\u7ec4\u3002<\/p>\n<p><strong>\u6b65\u9aa4\uff1a<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ol>\n<li>\n<p><strong>\u5bfc\u5165 Scanner \u7c7b\uff1a<\/strong><\/p>\n<pre>import java.util.Scanner;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p><strong>\u521b\u5efa Scanner \u5bf9\u8c61\uff1a<\/strong><\/p>\n<pre>Scanner scanner = new Scanner(System.in);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p><strong>\u63d0\u793a\u7528\u6237\u8f93\u5165\uff1a<\/strong><\/p>\n<pre>System.out.print(\"\u8bf7\u8f93\u5165\u6570\u7ec4\u5143\u7d20\uff08\u4ee5\u7a7a\u683c\u5206\u9694\uff09\uff1a\");<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p><strong>\u4f7f\u7528 nextLine() \u8bfb\u53d6\u4e00\u884c\u8f93\u5165\uff1a<\/strong><\/p>\n<pre>String input = scanner.nextLine();<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p><strong>\u5c06\u8f93\u5165\u5b57\u7b26\u4e32\u62c6\u5206\u4e3a\u6570\u7ec4\uff1a<\/strong><\/p>\n<pre>String[] array = input.split(\" \");<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ol>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>import java.util.Scanner;\n\npublic class ManualArrayInput {\n\n    public static void main(String[] args) {\n        Scanner scanner = new Scanner(System.in);\n\n        System.out.print(\"\u8bf7\u8f93\u5165\u6570\u7ec4\u5143\u7d20\uff08\u4ee5\u7a7a\u683c\u5206\u9694\uff09\uff1a\");\n        String input = scanner.nextLine();\n\n        String[] array = input.split(\" \");\n\n        \/\/ \u6253\u5370\u6570\u7ec4\u5143\u7d20\n        System.out.println(\"\u8f93\u5165\u7684\u6570\u7ec4\uff1a\");\n        for (String element : array) {\n            System.out.println(element);\n        }\n    }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u600e\u4e48\u624b\u52a8\u8f93\u5165\u4e00\u4e32\u6570\u7ec4\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>\u5728 java \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u624b\u52a8\u8f93\u5165\u4e00\u4e32\u6570\u7ec4\uff1a\u5bfc\u5165 scanner \u7c7b\uff1aimport java.util.scanner;\u521b\u5efa scanner \u5bf9\u8c61\uff1ascanner scanner = new scanner(system.in);\u63d0\u793a\u7528\u6237\u8f93\u5165\uff1asystem.out.print(&#8220;\u8bf7\u8f93\u5165\u6570\u7ec4\u5143\u7d20\uff08\u4ee5\u7a7a\u683c\u5206\u9694\uff09\uff1a&#8221;);\u4f7f\u7528 nextline() \u8bfb\u53d6\u4e00\u884c\u8f93\u5165\uff1astring input = scanner.nextline();\u5c06\u8f93\u5165\u5b57\u7b26\u4e32\u62c6\u5206\u4e3a\u6570\u7ec4\uff1astring[] array = inpu \u5982\u4f55\u5728 Java \u4e2d\u624b\u52a8\u8f93\u5165\u4e00\u4e32\u6570\u7ec4 \u56de\u7b54\uff1a \u5728 Java \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 Scanner \u7c7b\u6765\u624b\u52a8\u4ece\u63a7\u5236\u53f0\u8f93\u5165\u4e00\u4e32\u6570\u7ec4\u3002 \u6b65\u9aa4\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u5bfc\u5165 Scanner \u7c7b\uff1a import java.util.Scanner; \u767b\u5f55\u540e\u590d\u5236 \u521b\u5efa Scanner \u5bf9\u8c61\uff1a Scanner scanner = new Scanner(System.in); \u767b\u5f55\u540e\u590d\u5236 \u63d0\u793a\u7528\u6237\u8f93\u5165\uff1a System.out.print(&#8220;\u8bf7\u8f93\u5165\u6570\u7ec4\u5143\u7d20\uff08\u4ee5\u7a7a\u683c\u5206\u9694\uff09\uff1a&#8221;); \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528 nextLine() \u8bfb\u53d6\u4e00\u884c\u8f93\u5165\uff1a String input = [&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-39389","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/39389","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=39389"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/39389\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=39389"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=39389"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=39389"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}