{"id":1106,"date":"2022-05-17T20:34:42","date_gmt":"2022-05-17T12:34:42","guid":{"rendered":"https:\/\/sanlangcode.com\/?p=1106"},"modified":"2022-05-17T20:34:42","modified_gmt":"2022-05-17T12:34:42","slug":"java%e7%ac%94%e8%af%95%e5%b8%b8%e8%a7%81%e5%9f%ba%e6%9c%ac%e4%bb%a3%e7%a0%81%e6%a8%a1%e6%9d%bf%e6%8a%80%e5%b7%a7%ef%bc%88%e6%9b%b4%e6%96%b0%e4%b8%ad%ef%bc%89","status":"publish","type":"post","link":"https:\/\/sanlangcode.com\/index.php\/2022\/05\/17\/java%e7%ac%94%e8%af%95%e5%b8%b8%e8%a7%81%e5%9f%ba%e6%9c%ac%e4%bb%a3%e7%a0%81%e6%a8%a1%e6%9d%bf%e6%8a%80%e5%b7%a7%ef%bc%88%e6%9b%b4%e6%96%b0%e4%b8%ad%ef%bc%89\/","title":{"rendered":"Java\u7b14\u8bd5\u5e38\u89c1\u57fa\u672c\u4ee3\u7801\u6a21\u677f\u6280\u5de7\uff08\u66f4\u65b0\u4e2d\uff09"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>\/*\nAuthor:Sanro\nTime:2022.05.17 20:11:01\nBlog:https:\/\/sanlangcode.com\nEmail:sanlangcode@163.com\nDesc:\n*\/\n\nimport java.util.*;\nimport java.io.*;\n\npublic class Main {\n    public static void main(String&#91;] args) {\n        Scanner sc = new Scanner(System.in);\n\n    }\n}\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u51fd\u6570\n\u5b9a\u4e49\n\/\/    public static void function_name(\u53c2\u6570\u7c7b\u578b\uff0c\u53c2\u6570\u540d){\n\/\/\n\/\/        System.out.println(\"hello world\");\n\/\/\n\/\/    }<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u4e94\u79cdchar\u53d8\u6210String\n\/\/    \/\/1\n\/\/    String s1 = String.valueOf('c');\n\/\/    \/\/2\n\/\/    String s2 = String.valueOf(new char&#91;]{'c'});\n\/\/    \/\/3\n\/\/    String s3 = Character.toString('c');\n\/\/    \/\/4\n\/\/    String s4 = new Character('c').toString();\n\/\/    \/\/5\n\/\/    String s5 =\"\"+'c';<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\u628aString \u53d8\u6210Sting\u6570\u7ec4\n    String s = \"1 a,b c,d e\";\n    String&#91;] strs = s.split(\",\");<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code> \/\/1.\u8f93\u5165\u4e00\u4e2a\u6574\u6570\n\/\/    Scanner input_a = new Scanner(System.in);\n\/\/    int a = input_a.nextInt();\n\/\/    System.out.println(a);\n\/\/\n\/\/    \/\/2.\u8f93\u5165\u4e00\u4e2a\u5b57\u7b26\n\/\/    Scanner input_s = new Scanner(System.in);\n\/\/    String s = input_s.nextLine();\n\/\/    char to_s = s.charAt(0); \/\/\u628a\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u53d8\u6210\u5b57\u7b26\u6570\u7ec4\uff0c\u53ea\u53d6\u7b2c\u4e00\u4e2a\u5b57\u7b26\n\/\/    System.out.println(to_s);\n\/\/\n\/\/    \/\/3.\u8f93\u5165\u4e00\u4e2a\u5b57\u7b26\u4e32\n\/\/    Scanner input_str = new Scanner(System.in);\n\/\/    String str = input_s.next();\n\/\/    System.out.println(str);\n\/\/\n\/\/    \/\/4.\u8f93\u5165\u4e00\u884c\u5b57\u7b26\u4e32\n\/\/    Scanner input_str_cow = new Scanner(System.in);\n\/\/    String str_cow = input_str_cow.nextLine();\n\/\/    System.out.println(str_cow);\n\/\/\n\/\/    \/\/5.\u4e00\u884c\u8f93\u5165n\u4e2a\u6570\u5b57\n\/\/    Scanner input_num = new Scanner(System.in);\n\/\/    int n = input_num.nextInt();\n\/\/    int arr&#91;] = new int&#91;n];\n\/\/    for (int i = 0 ; i &lt; n ; i++ ){\n\/\/        arr&#91;i] = input_num.nextInt();\n\/\/    }\n\/\/    System.out.println(Arrays.toString(arr));\n\n    \/\/6.\u8f93\u5165\u4e00\u4e2a\u6574\u6570m\u884c\u7684\u7684\u77e9\u9635\uff08\u884c\u6570m \u6bcf\u884c\u7684\u5217\u6570\u4e0d\u5b9a\uff09\n\/\/    Scanner input_mn = new Scanner(System.in);\n\/\/    int m = Integer.parseInt(input_mn.nextLine());\n\/\/    for (int i = 0 ; i &lt; m ; i++){\n\/\/        String str = input_mn.nextLine();\n\/\/        System.out.println(str);\n\/\/    }\n\n    \/\/7.\u8f93\u5165\u4efb\u610f\u884c \u7a7a\u884c\u622a\u81f3\n\/\/    Scanner input_all = new Scanner(System.in);\n\/\/    String nextLine = input_all.nextLine();\n\/\/    while (nextLine != null &amp;&amp; !nextLine.equals(\"\")){\n\/\/        String&#91;] str = nextLine.split(\" \");\n\/\/        int&#91;] nums = new int&#91;str.length];\n\/\/        for ( int i = 0 ; i &lt; str.length ; i++){\n\/\/            nums&#91;i] = Integer.parseInt(str&#91;i]);\n\/\/        }\n\/\/        nextLine = input_all.nextLine();\n\/\/    }\n\n   \/\/8.\u6570\u5b57\u53d8\u5b57\u7b26+\u5b57\u7b26\u53d8\u6570\u7ec4\n    \/\/\u8f93\u5165\u4e00\u4e2a\u6570\u5b57\u628a\u4ed6\u53d8\u6210\u5b57\u7b26\u7c7b\u578b\uff0c\u8f93\u5165\u4e00\u4e2a\u5b57\u7b26\u4e3a\u6570\u5b57\u628a\u4ed6\u53d8\u6210\u6570\u5b57\u7c7b\u578b\u3002\n    \/\/char\u5b57\u7b26\u7c7b\u578b String\u5b57\u7b26\u4e32\u7c7b\u578b\n\/\/    Scanner input_num = new Scanner(System.in);\n\/\/    int num = input_num.nextInt();\n\/\/    System.out.println(num); \/\/\u63a5\u6536\u4e00\u4e2aint\u7c7b\u578b\u6570\u5b57\n\/\/\n\/\/    char num_char = (char)num;\/\/\u628aint\u7c7b\u578b\u53d8\u6210char \u4f1a\u8f93\u51fa\u5bf9\u5e94\u7684ASCII\u4ee3\u8868\u7684\u7b26\u53f7\n\/\/    System.out.println(num_char);\n\/\/\n\/\/    String num_str = String.valueOf(num);\/\/\u628aint\u53d8\u6210String\u7c7b\u578b\n\/\/    System.out.println(num_str);\n\/\/\n\/\/    int num_new = Integer.parseInt(num_str); \/\/\u628astring\u7c7b\u578b\u53d8\u6210int\n\/\/\n\/\/    char&#91;] num_list1 = num_str.toCharArray();\n\/\/    System.out.println(num_list1&#91;2]);\n\/\/    char&#91;] num_list2 = String.valueOf(num).toCharArray();\/\/\u628aint\u5148\u53d8\u6210string\u518d\u53d8\u6210char\u6570\u7ec4\n\/\/    System.out.println(num_list2&#91;1]);<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":1075,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-1106","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts\/1106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/comments?post=1106"}],"version-history":[{"count":0,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts\/1106\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/media\/1075"}],"wp:attachment":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/media?parent=1106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/categories?post=1106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/tags?post=1106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}