{"id":6317,"date":"2024-03-18T11:01:01","date_gmt":"2024-03-18T03:01:01","guid":{"rendered":""},"modified":"2024-03-18T11:01:01","modified_gmt":"2024-03-18T03:01:01","slug":"Java\u57fa\u7840\u4e4b Scanner \u626b\u63cf\u5668","status":"publish","type":"post","link":"https:\/\/mushiming.com\/6317.html","title":{"rendered":"Java\u57fa\u7840\u4e4b Scanner \u626b\u63cf\u5668"},"content":{"rendered":"
\n

\u5b66\u4e60Demo\uff1aDemo1<\/strong><\/p>\n<\/blockquote>\n

Scanner\u7c7b\uff1aJava\u7684\u8f93\u5165\u7c7b<\/p>\n

Scanner\u7c7b\u65e2\u53ef\u4ee5\u8bfb\u5b57\u7b26\uff0c\u4e5f\u53ef\u4ee5\u8bfb\u5b57\u7b26\u4e32\u548c\u6574\u6570<\/p>\n<\/p>\n

\"Java\u57fa\u7840\u4e4b<\/p>\n<\/p>\n

\n

\u7801\u4e0a\u884c\u52a8\uff1aDemo1<\/strong><\/p>\n<\/blockquote>\n

\"Java\u57fa\u7840\u4e4b<\/p>\n

import java.util.Scanner;\n\n\/**\n * Java\u7684\u8f93\u5165\u7c7b\n * Scanner\u7c7b\u65e2\u53ef\u4ee5\u8bfb\u5b57\u7b26\uff0c\u4e5f\u53ef\u4ee5\u8bfb\u5b57\u7b26\u4e32\u548c\u6574\u6570\n * @Author Hateyes\n * @Date 2020-07-25 10:37\n *\/\npublic class ScannerDemo {\n\n    public static void main(String[] args) {\n        Scanner scanner = new Scanner(System.in);\n        System.out.println(\"\u8bf7\u8f93\u5165\u60a8\u7684\u59d3\u540d\uff1a\");\n        String name = scanner.nextLine();\n        System.out.println(\"\u8bf7\u8f93\u5165\u60a8\u7684\u5e74\u9f84\uff1a\");\n        int age = scanner.nextInt();\n        System.out.println(\"\u8bf7\u8f93\u5165\u60a8\u7684\u5de5\u8d44\uff1a\");\n        float salary = scanner.nextFloat();\n        System.out.println(\"\u60a8\u7684\u4fe1\u606f\u5982\u4e0b\uff1a\");\n        System.out.println(\"\u59d3\u540d\uff1a\" + name + \"\\n\" + \"\u5e74\u9f84\uff1a\" + age + \"\\n\" + \"\u5de5\u8d44\uff1a\" + salary); \/\/ '\\n'\u4e3a\u6362\u884c '\\r'\u4e3a\u56de\u8f66 '\\t'\u4e3a\u5236\u8868\u7b26(tab) '\\f'\u4e3a\u6362\u9875\n    }\n\n}\n<\/pre>\n
\n

\u5b66\u4e60Demo\uff1aDemo2<\/strong><\/p>\n<\/blockquote>\n

Scanner \u626b\u63cf\u5668\uff1ajava.util.Scanner<\/p>\n

    \n
  1. \n

    Scanner.next() \u65b9\u6cd5\u83b7\u53d6\u8f93\u5165\u7684\u5b57\u7b26\u4e32<\/p>\n<\/li>\n

  2. \n

    Scan<\/p>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"Java\u57fa\u7840\u4e4b Scanner \u626b\u63cf\u5668\u5b66\u4e60Demo\uff1aDemo1Scanner\u7c7b\uff1aJava\u7684\u8f93\u5165\u7c7bScanner\u7c7b\u65e2\u53ef\u4ee5\u8bfb\u5b57\u7b26\uff0c\u4e5f\u53ef\u4ee5\u8bfb\u5b57\u7b26\u4e32\u548c\u6574\u6570\u7801\u4e0a\u884c\u52a8\uff1aD...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/6317"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=6317"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/6317\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=6317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=6317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=6317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}