{"id":4055,"date":"2024-04-27T08:24:40","date_gmt":"2024-04-27T00:24:40","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/index.php\/%e9%9d%a2%e8%af%95\/%e5%ad%97%e8%8a%82%e9%9d%a2%e8%af%95%e9%a2%98%ef%bc%9ajava%e4%b8%ad%e5%a6%82%e6%9e%9c%e4%b8%a4%e4%b8%aa%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%af%b9%e8%b1%a1%e6%9c%89%e7%9b%b8%e5%90%8c%e7%9a%84%e5%80%bc\/"},"modified":"2024-04-27T08:24:40","modified_gmt":"2024-04-27T00:24:40","slug":"%e5%ad%97%e8%8a%82%e9%9d%a2%e8%af%95%e9%a2%98%ef%bc%9ajava%e4%b8%ad%e5%a6%82%e6%9e%9c%e4%b8%a4%e4%b8%aa%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%af%b9%e8%b1%a1%e6%9c%89%e7%9b%b8%e5%90%8c%e7%9a%84%e5%80%bc","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/%e9%9d%a2%e8%af%95\/%e5%ad%97%e8%8a%82%e9%9d%a2%e8%af%95%e9%a2%98%ef%bc%9ajava%e4%b8%ad%e5%a6%82%e6%9e%9c%e4%b8%a4%e4%b8%aa%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%af%b9%e8%b1%a1%e6%9c%89%e7%9b%b8%e5%90%8c%e7%9a%84%e5%80%bc\/","title":{"rendered":"\u5b57\u8282\u9762\u8bd5\u9898\uff1aJava\u4e2d\u5982\u679c\u4e24\u4e2a\u5b57\u7b26\u4e32\u5bf9\u8c61\u6709\u76f8\u540c\u7684\u503c\uff0c\u5b83\u4eec\u4f1a\u5b58\u50a8\u5728\u5e38\u91cf\u6c60\u4e2d\u7684\u540c\u4e00\u4e2a\u4f4d\u7f6e\u5417\uff1f"},"content":{"rendered":"<div class='wxsyncmain'>\n<p data-v-md-line=\"1\"><span style=\"font-size: 15px;\">\u5728Java\u4e2d\uff0c\u5b57\u7b26\u4e32\u5e38\u91cf\u6c60\u662f\u4e00\u4e2a\u7279\u6b8a\u7684\u5b58\u50a8\u533a\u57df\uff0c\u7528\u6765\u7f13\u5b58\u7ecf\u5e38\u4f7f\u7528\u7684\u5b57\u7b26\u4e32\u5b57\u9762\u91cf\u3002\u5f53\u4f60\u5728Java\u7a0b\u5e8f\u4e2d\u521b\u5efa\u5b57\u7b26\u4e32\u5b57\u9762\u91cf\u65f6\uff0cJVM\u4f1a\u9996\u5148\u68c0\u67e5\u5b57\u7b26\u4e32\u5e38\u91cf\u6c60\u4e2d\u662f\u5426\u5df2\u7ecf\u5b58\u5728\u76f8\u540c\u5185\u5bb9\u7684\u5b57\u7b26\u4e32\u3002\u5982\u679c\u5b58\u5728\uff0c\u5c31\u4f1a\u8fd4\u56de\u5bf9\u8be5\u5b57\u7b26\u4e32\u7684\u5f15\u7528\uff0c\u800c\u4e0d\u662f\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5bf9\u8c61\u3002\u5982\u679c\u4e0d\u5b58\u5728\uff0c\u5b83\u5c06\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5b57\u7b26\u4e32\u5bf9\u8c61\uff0c\u5e76\u653e\u5165\u5b57\u7b26\u4e32\u5e38\u91cf\u6c60\u4e2d\u3002<\/span><\/p>\n<p data-v-md-line=\"3\"><strong><span style=\"font-size: 15px;\">\u8fd9\u91cc\u6709\u51e0\u4e2a\u573a\u666f\u9700\u8981\u8003\u8651\uff1a<\/span><\/strong><span style=\"font-size: 15px;\"><\/span><\/p>\n<p><strong><span style=\"font-size: 20px;\">1\u3001\u5b57\u7b26\u4e32\u5b57\u9762\u91cf\uff1a<\/span><\/strong><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"javascript\"><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__built_in\">String<\/span> s1 = <span class=\"code-snippet__string\">\"example\"<\/span>;<\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__built_in\">String<\/span> s2 = <span class=\"code-snippet__string\">\"example\"<\/span>;<\/span><\/code><\/pre>\n<\/section>\n<p data-v-md-line=\"10\"><span style=\"font-size: 15px;\">\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0cs1 \u548c s2 \u662f\u901a\u8fc7\u5b57\u7b26\u4e32\u5b57\u9762\u91cf\u521b\u5efa\u7684\uff0c\u5e76\u6307\u5411\u5e38\u91cf\u6c60\u4e2d\u76f8\u540c\u7684\u5bf9\u8c61\u3002\u56e0\u6b64\uff0c<strong>s1 == s2 \u5c06\u8fd4\u56de true<\/strong>\u3002<\/span><\/p>\n<p><strong><span style=\"font-size: 20px;\">2\u3001\u4f7f\u7528new\u5173\u952e\u5b57\u521b\u5efa\u7684\u5b57\u7b26\u4e32\u5bf9\u8c61\uff1a<\/span><\/strong><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"javascript\"><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__built_in\">String<\/span> s3 = <span class=\"code-snippet__keyword\">new<\/span> <span class=\"code-snippet__built_in\">String<\/span>(<span class=\"code-snippet__string\">\"example\"<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__built_in\">String<\/span> s4 = <span class=\"code-snippet__keyword\">new<\/span> <span class=\"code-snippet__built_in\">String<\/span>(<span class=\"code-snippet__string\">\"example\"<\/span>);<\/span><\/code><\/pre>\n<\/section>\n<p data-v-md-line=\"17\"><span style=\"font-size: 15px;\">\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0cs3 \u548c s4 \u662f\u901a\u8fc7 new \u5173\u952e\u5b57\u521b\u5efa\u7684\uff0c\u5b83\u4eec\u90fd\u5728\u5806\u5185\u5b58\u4e2d\u6307\u5411\u4e0d\u540c\u7684\u5bf9\u8c61\u3002\u5c3d\u7ba1 s3 \u548c s4 \u5305\u542b\u76f8\u540c\u7684\u5b57\u7b26\u4e32\u503c\uff0c\u4f46\u5b83\u4eec\u662f\u4e24\u4e2a\u72ec\u7acb\u7684\u5bf9\u8c61\uff0c\u56e0\u6b64 <strong>s3 == s4 \u4f1a\u8fd4\u56de false<\/strong>\u3002<\/span><\/p>\n<p data-v-md-line=\"19\"><span style=\"font-size: 15px;\">\u4f46\u662f\uff0c\u5b57\u7b26\u4e32\u5bf9\u8c61\u53ef\u4ee5\u88ab\u663e\u5f0f\u5730\u8f6c\u79fb\u5230\u5b57\u7b26\u4e32\u5e38\u91cf\u6c60\u4e2d\uff0c\u8fd9\u901a\u5e38\u662f\u901a\u8fc7\u8c03\u7528 intern()\u65b9\u6cd5\u5b9e\u73b0\u7684\u3002<\/span><\/p>\n<p><strong><span style=\"font-size: 20px;\">3\u3001\u4f7f\u7528intern()\u65b9\u6cd5\u7684\u60c5\u51b5\uff1a<\/span><\/strong><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"javascript\"><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__built_in\">String<\/span> s5 = <span class=\"code-snippet__keyword\">new<\/span> <span class=\"code-snippet__built_in\">String<\/span>(<span class=\"code-snippet__string\">\"example\"<\/span>).intern();<\/span><\/code><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__built_in\">String<\/span> s6 = <span class=\"code-snippet__string\">\"example\"<\/span>;<\/span><\/code><\/pre>\n<\/section>\n<p data-v-md-line=\"26\"><span style=\"font-size: 15px;\">\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0cs5 \u662f\u901a\u8fc7 new \u521b\u5efa\u7136\u540e\u8c03\u7528\u4e86 intern()\u65b9\u6cd5\uff0c\u8fd9\u4f1a\u5f3a\u5236\u68c0\u67e5\u5b57\u7b26\u4e32\u5e38\u91cf\u6c60\u4e2d\u662f\u5426\u6709\"example\"\u5b57\u7b26\u4e32\u3002\u7531\u4e8e\"example\"\u5b57\u9762\u91cf\u5df2\u7ecf\u5b58\u5728\u4e8e\u5e38\u91cf\u6c60\u4e2d\uff08\u56e0\u4e3a\u7f16\u8bd1\u5668\u5c06\u5176\u6dfb\u52a0\u5230\u4e86\u6c60\u4e2d\uff09\uff0cintern()\u65b9\u6cd5\u4f1a\u8fd4\u56de\u5bf9\u90a3\u4e2a\u5df2\u7ecf\u5b58\u5728\u7684\u6c60\u4e2d\u5b57\u7b26\u4e32\u5bf9\u8c61\u7684\u5f15\u7528\u3002\u56e0\u6b64\uff0cs5 \u6700\u7ec8\u4f1a\u5f15\u7528\u548c s6 \u76f8\u540c\u7684\u5b57\u7b26\u4e32\u5bf9\u8c61\uff0c<strong>\u6240\u4ee5 s5 == s6 \u5c06\u8fd4\u56de true\u3002<\/strong><\/span><\/p>\n<p data-v-md-line=\"28\"><span style=\"font-size: 15px;\">\u603b\u7ed3\uff1a\u5b57\u7b26\u4e32\u5e38\u91cf\u6c60\u5e2e\u52a9\u8282\u7701\u5185\u5b58\u7a7a\u95f4\uff0c\u907f\u514d\u91cd\u590d\u521b\u5efa\u62e5\u6709\u76f8\u540c\u5185\u5bb9\u7684\u5b57\u7b26\u4e32\u5bf9\u8c61\u3002\u53ea\u6709\u901a\u8fc7<strong>\u5b57\u7b26\u4e32\u5b57\u9762\u91cf\u6216\u8005intern()\u65b9\u6cd5<\/strong>\u5f97\u5230\u7684\u5b57\u7b26\u4e32\u5bf9\u8c61\u624d\u4f1a\u6307\u5411\u5e38\u91cf\u6c60\u4e2d\u76f8\u540c\u7684\u4f4d\u7f6e\u3002\u901a\u8fc7 new \u5173\u952e\u5b57\u521b\u5efa\u7684\u5b57\u7b26\u4e32\u5bf9\u8c61<strong>\u4e0d\u4f1a\u81ea\u52a8\u5b58\u50a8\u5728\u5e38\u91cf\u6c60\u4e2d<\/strong>\uff0c\u9664\u975e\u8c03\u7528\u4e86 intern()\u65b9\u6cd5\u3002<\/span><span style=\"font-size: 15px;letter-spacing: 0.034em;\"><\/span><\/p>\n<p style=\"display: none;\"><mp-style-type data-value=\"3\"><\/mp-style-type><\/p>\n<blockquote>\n<p>\u672c\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8e\u5fae\u4fe1\u516c\u4f17\u53f7:                 \u4e92\u8054\u7f51\u9762\u8bd5\u5c0f\u5e2e\u624b              <\/p>\n<\/blockquote>\n<\/div>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>\u5728Java\u4e2d\uff0c\u5b57\u7b26\u4e32\u5e38\u91cf\u6c60\u662f\u4e00\u4e2a\u7279\u6b8a\u7684\u5b58\u50a8\u533a\u57df\uff0c\u7528\u6765\u7f13\u5b58\u7ecf\u5e38\u4f7f\u7528\u7684\u5b57\u7b26\u4e32\u5b57\u9762\u91cf\u3002\u5f53\u4f60\u5728Java\u7a0b\u5e8f\u4e2d\u521b\u5efa\u5b57\u7b26\u4e32\u5b57\u9762\u91cf\u65f6\uff0cJVM\u4f1a\u9996 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":4052,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[30],"tags":[],"class_list":["post-4055","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-30"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524144822922-150x150.jpeg","content_first_image":null,"post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524144822922-300x128.jpeg","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524144822922.jpeg","post_frist_image":null,"post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524144822922-300x128.jpeg","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524144822922.jpeg","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524144822922.jpeg","post_all_images":[],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"\u9762\u8bd5","post_date":"2024-04-27","like_count":"0","praiseWord":"\u9f13\u52b1","copyright_state":"","excitationAd":"0","rewardedVideoAdId":"","detailAdId":"","detailAd":"0","enterpriseMinapp":"0","audios":[],"postImageUrl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230519082947553.jpg","avatarurls":[],"related_posts":null,"pageviews":281,"next_post_id":4051,"next_post_title":"\u817e\u8baf\u4e00\u9762\uff1a\u4e3a\u4ec0\u4e48volatile\u4e0d\u80fd\u4fdd\u8bc1\u590d\u5408\u64cd\u4f5c\uff08\u5982\u81ea\u589e\u64cd\u4f5c i++\uff09\u7684\u7ebf\u7a0b\u5b89\u5168\uff1f","previous_post_id":4067,"previous_post_title":"\u817e\u8baf\u9762\u8bd5\u9898\uff1aJava\u4e2d\u4ec0\u4e48\u60c5\u51b5\u4e0b\u4f1a\u89e6\u53d1Minor GC\u548cFull GC\uff1f","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/4055","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/comments?post=4055"}],"version-history":[{"count":0,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/4055\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media\/4052"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=4055"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=4055"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=4055"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}