{"id":759,"date":"2022-10-07T18:32:04","date_gmt":"2022-10-07T10:32:04","guid":{"rendered":"https:\/\/qaqaq.top\/?p=759"},"modified":"2022-11-27T12:39:54","modified_gmt":"2022-11-27T04:39:54","slug":"%e9%9d%a2%e5%90%91%e5%af%b9%e8%b1%a1%e4%b8%ad-%e5%9f%ba%e6%9c%ac%e6%95%b0%e6%8d%ae%e7%b1%bb%e5%9e%8b%e8%bd%ac%e6%8d%a2%e4%b8%ba%e5%8c%85%e8%a3%85%e7%b1%bb%e3%80%81%e5%9f%ba%e6%9c%ac%e6%95%b0","status":"publish","type":"post","link":"https:\/\/qaqaq.top\/?p=759","title":{"rendered":"\u9762\u5411\u5bf9\u8c61(\u4e2d)-\u57fa\u672c\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u4e3a\u5305\u88c5\u7c7b\u3001\u57fa\u672c\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u4e3a\u5305\u88c5\u7c7b\u3001\u65b0\u7279\u6027\uff1a\u81ea\u52a8\u88c5\u7bb1\u4e0e\u81ea\u52a8\u62c6\u7bb1\u3001\u57fa\u672c\u6570\u636e\u7c7b\u578b\u5305\u88c5\u7c7b\u4e0eString\u7684\u76f8\u4e92\u8f6c\u6362"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>package top.qaqaq.java.P305;\r\n\r\nimport org.junit.Test;\r\n\r\n\/*\r\n * \u5305\u88c5\u7c7b\u7684\u4f7f\u7528\uff1a\r\n * 1. java\u63d0\u4f9b\u4e868\u79cd\u57fa\u672c\u6570\u636e\u7c7b\u578b\u5bf9\u5e94\u7684\u5305\u88c5\u7c7b\uff0c\u4f7f\u5f97\u57fa\u672c\u6570\u636e\u7c7b\u578b\u7684\u53d8\u91cf\u5177\u6709\u7c7b\u7684\u7279\u5f81\r\n * \r\n * 2. \u638c\u63e1\u7684\uff1a\u57fa\u672c\u6570\u636e\u7c7b\u578b\u3001\u5305\u88c5\u7c7b\u3001String\u4e09\u8005\u4e4b\u95f4\u7684\u76f8\u4e92\u8f6c\u6362\r\n * \r\n * \r\n * \r\n * \r\n * \r\n * \r\n * \r\n *\/\r\npublic class WrapperTest {\r\n\t\r\n\t\/\/String\u7c7b\u578b--->\u57fa\u672c\u6570\u636e\u7c7b\u578b\u3001\u5305\u88c5\u7c7b\uff1a\u8c03\u7528\u5305\u88c5\u7c7b\u7684ParseXxx(String s)\r\n\t@Test\r\n\tpublic void test5() {\r\n\t\tString str1 = \"123\";\r\n\t\t\/\/\u9519\u8bef\u7684\u60c5\u51b5\uff1a\r\n\/\/\t\tint num1 = (int)str1;\r\n\/\/\t\tInteger in1 = (Integer)str1;\r\n\t\t\/\/\u53ef\u80fd\u4f1a\u62a5NumberFormatException\r\n\t\tint num2 = Integer.parseInt(str1);\r\n\t\tSystem.out.println(num2 + 1);\r\n\t\t\r\n\t\tString str2 = \"true1\";\r\n\t\tboolean b1 = Boolean.parseBoolean(str2);\r\n\t\tSystem.out.println(b1);\r\n\t\t\r\n\t}\r\n\t\r\n\t\/\/\u57fa\u672c\u6570\u636e\u7c7b\u578b\u3001\u5305\u88c5\u7c7b--->String\u7c7b\u578b\uff1a\u8c03\u7528String\u91cd\u8f7d\u7684valueOf(Xxx xxx)\r\n\t@Test\r\n\tpublic void test4() {\r\n\t\t\r\n\t\tint num1 = 10;\r\n\t\t\/\/\u65b9\u5f0f1\uff1a\u8fde\u63a5\u8fd0\u7b97\r\n\t\tString str1 = num1 + \"\";\r\n\t\t\/\/\u65b9\u5f0f2\uff1a\u8c03\u7528String\u7684valueOf(Xxx xxx)\r\n\t\tfloat f1 = 12.3f;\r\n\t\tString str2 = String.valueOf(f1);\/\/\"12.3\"\r\n\t\t\r\n\t\tDouble d1 = new Double(12.4);\r\n\t\tString str3 = String.valueOf(d1);\r\n\t\t\r\n\t\tSystem.out.println(str2);\r\n\t\tSystem.out.println(str3);\/\/\"12.4\"\r\n\t}\r\n\t\r\n\t\/*\r\n\t * JDK 5.0\u65b0\u7279\u6027\uff1a\u81ea\u52a8\u88c5\u7bb1\u4e0e\u81ea\u52a8\u62c6\u7bb1\r\n\t *\/\r\n\t@Test\r\n\tpublic void test3() {\r\n\/\/\t\tint num1 = 10;\r\n\/\/\t\t\/\/\u57fa\u672c\u6570\u636e\u7c7b\u578b-->\u5305\u88c5\u7c7b\u7684\u5bf9\u8c61\r\n\/\/\t\tmethod(num1);\r\n\t\t\r\n\t\t\/\/\u81ea\u52a8\u88c5\u7bb1\uff1a\u57fa\u672c\u6570\u636e\u7c7b\u578b--->\u5305\u88c5\u7c7b\r\n\t\tint num2 = 10;\r\n\t\tInteger in1 = num2;\/\/\u81ea\u52a8\u88c5\u7bb1\r\n\t\t\r\n\t\tboolean b1 = true;\r\n\t\tBoolean b2 = b1;\/\/\u81ea\u52a8\u88c5\u7bb1\r\n\t\t\r\n\t\t\/\/\u81ea\u52a8\u62c6\u7bb1\uff1a\u5305\u88c5\u7c7b--->\u57fa\u672c\u6570\u636e\u7c7b\u578b\r\n\t\tSystem.out.println(in1.toString());\r\n\t\tint num3 = in1;\/\/\u81ea\u52a8\u62c6\u7bb1\r\n\t\t\r\n\t}\r\n\t\r\n\tpublic void method(Object obj) {\r\n\t\tSystem.out.println(obj);\r\n\t}\r\n\t\r\n\t\/\/\u5305\u88c5\u7c7b--->\u57fa\u672c\u6570\u636e\u7c7b\u578b:\u8c03\u7528\u5305\u88c5\u7c7b\u7684xxxValue()\r\n\t@Test\r\n\tpublic void test2() {\r\n\t\tInteger in1 = new Integer(12);\r\n\t\t\r\n\t\tint i1 = in1.intValue();\r\n\t\tSystem.out.println(i1 + 1);\r\n\t\t\r\n\t\tFloat f1 = new Float(12.3);\r\n\t\tfloat f2 = f1.floatValue();\r\n\t\tSystem.out.println(f2 + 1);\r\n\t}\r\n\r\n\t\/\/\u57fa\u672c\u6570\u636e\u7c7b\u578b--->\u5305\u88c5\u7c7b\uff1a\u8c03\u7528\u5305\u88c5\u7c7b\u7684\u6784\u9020\u5668\r\n\t@Test\r\n\tpublic void test1() {\r\n\t\t\r\n\t\tint num1 = 10;\r\n\/\/\t\tSystem.out.println(num1.toString());\r\n\t\tInteger in1 = new Integer(num1);\r\n\t\t\r\n\t\t\/\/The constructor Integer(int) is deprecated since version 9,\u81ea\u7248\u672c 9 \u8d77\uff0c\u6784\u9020\u51fd\u6570 Integer(int) \u5df2\u5f03\u7528\r\n\t\t\/\/The value of the local variable in1 is not used,\u672a\u4f7f\u7528\u5c40\u90e8\u53d8\u91cf in1 \u7684\u503c\r\n\t\t\/\/\u5b98\u65b9\u63a8\u8350\u4f7f\u7528ValueOf\u65b9\u6cd5\u6765\u6784\u5efa\u5305\u3002\r\n\t\tInteger in11 = Integer.valueOf(num1);\r\n\t\t\r\n\t\tSystem.out.println(in1.toString());\r\n\t\t\r\n\t\tInteger in2 = new Integer(\"123\");\r\n\t\tSystem.out.println(in2.toString());\r\n\t\t\r\n\t\t\/\/\u62a5\u5f02\u5e38\r\n\/\/\t\tInteger in3 = new Integer(\"123abc\");\r\n\/\/\t\tSystem.out.println(in3.toString());\r\n\t\t\r\n\t\tFloat f1 = new Float(12.3f);\r\n\t\tFloat f2 = new Float(\"12.3\");\r\n\t\tSystem.out.println(f1);\r\n\t\tSystem.out.println(f2);\r\n\t\t\r\n\t\tBoolean b1 = new Boolean(true);\r\n\t\tBoolean b2 = new Boolean(\"TrUe\");\r\n\t\tSystem.out.println(b2);\r\n\t\tboolean b3 = new Boolean(\"true123\");\r\n\t\tSystem.out.println(b3);\/\/false\r\n\t\t\r\n\t\tOrder order = new Order();\r\n\t\tSystem.out.println(order.isMale);\/\/false\r\n\t\tSystem.out.println(order.isFemale);\/\/null\r\n\t}\r\n}\r\n\r\nclass Order{\r\n\t\r\n\tboolean isMale;\r\n\tBoolean isFemale;\r\n}\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[46],"class_list":["post-759","post","type-post","status-publish","format-standard","hentry","category-java-code","tag-java"],"_links":{"self":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/759"}],"collection":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=759"}],"version-history":[{"count":1,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/759\/revisions"}],"predecessor-version":[{"id":760,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/759\/revisions\/760"}],"wp:attachment":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=759"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=759"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=759"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}