{"id":10006899,"date":"2022-11-23T09:57:26","date_gmt":"2022-11-23T01:57:26","guid":{"rendered":"https:\/\/ityet.com\/?p=10006899"},"modified":"2022-11-23T09:57:26","modified_gmt":"2022-11-23T01:57:26","slug":"java-%e5%86%85%e9%83%a8%e7%b1%bb%e6%9c%89%e5%9d%91%e3%80%82%e3%80%82100-%e5%86%85%e5%ad%98%e6%b3%84%e9%9c%b2%ef%bc%81","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10006899","title":{"rendered":"Java \u5185\u90e8\u7c7b\u6709\u5751\u3002\u3002100 % \u5185\u5b58\u6cc4\u9732\uff01"},"content":{"rendered":"<p>\u6765\u6e90\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=vMabZ9Nn%2BoWvyfXvqyj53A%3D%3D.Zsr6A0o9%2FOqvNQUPVEjh2TD03HrkqGawXiF20YkQLOkoCbbloiptcD5l%2FYbjDYWy%2BrP4x6Ng0rJQ58lnauKpAA%3D%3D\" rel=\"nofollow\">https:\/\/knife.blog.csdn.net\/a&#8230;<\/a><\/p>\n<p>\u4eca\u5929\u7ed9\u5927\u5bb6\u5206\u4eab\u4e00\u79cd\uff0cJava\u5185\u90e8\u7c7b\u4f7f\u7528\u4e0d\u5f53\u5bfc\u81f4\u7684\u5185\u5b58\u6cc4\u9732\u95ee\u9898\uff0c\u6700\u7ec8\u5bfc\u81f4\u5185\u5b58\u6ea2\u51fa\uff01\u5e0c\u671b\u80fd\u591f\u5e2e\u52a9\u5230\u5927\u5bb6\uff01<\/p>\n<h2>\u7b80\u4ecb<\/h2>\n<p><strong>\u300c\u8bf4\u660e\u300d<\/strong><\/p>\n<p>\u672c\u6587\u4ecb\u7ecd Java \u5185\u90e8\u7c7b\u6301\u6709\u5916\u90e8\u7c7b\u5bfc\u81f4\u5185\u5b58\u6cc4\u9732\u7684\u539f\u56e0\u4ee5\u53ca\u5176\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<p><strong>\u300c\u4e3a\u4ec0\u4e48\u5185\u90e8\u7c7b\u6301\u6709\u5916\u90e8\u7c7b\u4f1a\u5bfc\u81f4\u5185\u5b58\u6cc4\u9732\uff1f\u300d<\/strong><\/p>\n<p>\u975e\u9759\u6001\u5185\u90e8\u7c7b\u4f1a\u6301\u6709\u5916\u90e8\u7c7b\uff0c\u5982\u679c\u6709\u5730\u65b9\u5f15\u7528\u4e86\u8fd9\u4e2a\u975e\u9759\u6001\u5185\u90e8\u7c7b\uff0c\u4f1a\u5bfc\u81f4\u5916\u90e8\u7c7b\u4e5f\u88ab\u5f15\u7528\uff0c\u5783\u573e\u56de\u6536\u65f6\u65e0\u6cd5\u56de\u6536\u8fd9\u4e2a\u5916\u90e8\u7c7b\uff08\u5373\u4f7f\u5916\u90e8\u7c7b\u5df2\u7ecf\u6ca1\u6709\u5176\u4ed6\u5730\u65b9\u5728\u4f7f\u7528\u4e86\uff09\u3002<\/p>\n<p><strong>\u300c\u89e3\u51b3\u65b9\u6848\u300d<\/strong><\/p>\n<ol>\n<li>\u4e0d\u8981\u8ba9\u5176\u4ed6\u7684\u5730\u65b9\u6301\u6709\u8fd9\u4e2a\u975e\u9759\u6001\u5185\u90e8\u7c7b\u7684\u5f15\u7528\uff0c\u76f4\u63a5\u5728\u8fd9\u4e2a\u975e\u9759\u6001\u5185\u90e8\u7c7b\u6267\u884c\u4e1a\u52a1\u3002<\/li>\n<li>\u5c06\u975e\u9759\u6001\u5185\u90e8\u7c7b\u6539\u4e3a\u9759\u6001\u5185\u90e8\u7c7b\u3002\u5185\u90e8\u7c7b\u6539\u4e3a\u9759\u6001\u7684\u4e4b\u540e\uff0c\u5b83\u6240\u5f15\u7528\u7684\u5bf9\u8c61\u6216\u5c5e\u6027\u4e5f\u5fc5\u987b\u662f\u9759\u6001\u7684\uff0c\u6240\u4ee5\u9759\u6001\u5185\u90e8\u7c7b\u65e0\u6cd5\u83b7\u5f97\u5916\u90e8\u5bf9\u8c61\u7684\u5f15\u7528\uff0c\u53ea\u80fd\u4ece JVM \u7684 Method Area\uff08\u65b9\u6cd5\u533a\uff09\u83b7\u53d6\u5230static\u7c7b\u578b\u7684\u5f15\u7528\u3002<\/li>\n<\/ol>\n<h2>\u4e3a\u4ec0\u4e48\u8981\u6301\u6709\u5916\u90e8\u7c7b<\/h2>\n<p>Java \u8bed\u8a00\u4e2d\uff0c\u975e\u9759\u6001\u5185\u90e8\u7c7b\u7684\u4e3b\u8981\u4f5c\u7528\u6709\u4e24\u4e2a\uff1a<\/p>\n<ol>\n<li>\u5f53\u5185\u90e8\u7c7b\u53ea\u5728\u5916\u90e8\u7c7b\u4e2d\u4f7f\u7528\u65f6\uff0c\u533f\u540d\u5185\u90e8\u7c7b\u53ef\u4ee5\u8ba9\u5916\u90e8\u4e0d\u77e5\u9053\u5b83\u7684\u5b58\u5728\uff0c\u4ece\u800c\u51cf\u5c11\u4e86\u4ee3\u7801\u7684\u7ef4\u62a4\u5de5\u4f5c\u3002<\/li>\n<li>\u5f53\u5185\u90e8\u7c7b\u6301\u6709\u5916\u90e8\u7c7b\u65f6\uff0c\u5b83\u5c31\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u5916\u90e8\u7c7b\u4e2d\u7684\u53d8\u91cf\u4e86\uff0c\u8fd9\u6837\u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u5b8c\u6210\u8c03\u7528\uff0c\u5982\u4e0b\u4ee3\u7801\u6240\u793a\uff1a<\/li>\n<\/ol>\n<pre><code>package org.example.a;\n\nclass Outer{\n    private String outerName = &quot;Tony&quot;;\n\n    class Inner{\n        private String name;\n\n        public Inner() {\n            this.name = outerName;\n        }\n    }\n\n    Inner createInner() {\n        return new Inner();\n    }\n}\n\npublic class Demo {\n    public static void main(String[] args) {\n        Outer.Inner inner = new Outer().createInner();\n        System.out.println(inner);\n    }\n}<\/code><\/pre>\n<p>\u4f46\u662f\uff0c\u9759\u6001\u5185\u90e8\u7c7b\u5c31\u65e0\u6cd5\u6301\u6709\u5916\u90e8\u7c7b\u548c\u5176\u975e\u9759\u6001\u5b57\u6bb5\u4e86\u3002\u53e6\u5916\uff0c\u6700\u65b0 Java \u9762\u8bd5\u9898\u6574\u7406\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=F5rxzSjAk2BPqoLBKQOaRw%3D%3D.v%2BRybI9a4Ph7O2d0m1dw0tiaVzzYRLAKHI6t65cUBOk%3D\" rel=\"nofollow\">https:\/\/www.javastack.cn\/mst\/<\/a><\/p>\n<p>\u6bd4\u5982\u4e0b\u8fb9\u8fd9\u6837\u5c31\u4f1a\u62a5\u9519<\/p>\n<pre><code>package org.example.a;\n\nclass Outer{\n    private String outerName = &quot;Tony&quot;;\n\n    static class Inner{\n        private String name;\n\n        public Inner() {\n            this.name = outerName;\n        }\n    }\n\n    Inner createInner() {\n        return new Inner();\n    }\n}\n\npublic class Demo {\n    public static void main(String[] args) {\n        Outer.Inner inner = new Outer().createInner();\n        System.out.println(inner);\n    }\n}<\/code><\/pre>\n<p>\u62a5\u9519\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc32FE\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h2>\u5b9e\u4f8b\uff1a\u6301\u6709\u5916\u90e8\u7c7b<\/h2>\n<p><strong>\u300c\u4ee3\u7801\u300d<\/strong><\/p>\n<pre><code>package org.example.a;\n\nclass Outer{\n    class Inner {\n\n    }\n\n    Inner createInner() {\n        return new Inner();\n    }\n}\n\npublic class Demo {\n    public static void main(String[] args) {\n        Outer.Inner inner = new Outer().createInner();\n        System.out.println(inner);\n    }\n}<\/code><\/pre>\n<p><strong>\u300c\u65ad\u70b9\u8c03\u8bd5\u300d<\/strong><\/p>\n<p>\u53ef\u4ee5\u770b\u5230\uff1a\u5185\u90e8\u7c7b\u6301\u6709\u5916\u90e8\u7c7b\u7684\u5bf9\u8c61\u7684\u5f15\u7528\uff0c\u662f\u4ee5\u201cthis$0\u201d\u8fd9\u4e2a\u5b57\u6bb5\u6765\u4fdd\u5b58\u7684\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc32FF\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h2>\u5b9e\u4f8b\uff1a\u4e0d\u6301\u6709\u5916\u90e8\u7c7b<\/h2>\n<p><strong>\u300c\u4ee3\u7801\u300d<\/strong><\/p>\n<pre><code>package org.example.a;\n\nclass Outer{\n    static class Inner {\n\n    }\n\n    Inner createInner() {\n        return new Inner();\n    }\n}\n\npublic class Demo {\n    public static void main(String[] args) {\n        Outer.Inner inner = new Outer().createInner();\n        System.out.println(inner);\n    }\n}<\/code><\/pre>\n<p>\u66f4\u591a Java \u6559\u7a0b\u53ca\u793a\u4f8b\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=4If1Ft9F0SH3dMskcbBeog%3D%3D.s98%2B64UKpFDlCeq2mxoK1j2EeSmpV2CHmwoIvJF%2FE5LKzqtP8iMOcLhvDMVYuoJ6\" rel=\"nofollow\">https:\/\/github.com\/javastacks\/javastack<\/a><\/p>\n<p><strong>\u300c\u65ad\u70b9\u8c03\u8bd5\u300d<\/strong><\/p>\n<p>\u53ef\u4ee5\u53d1\u73b0\uff1a\u5185\u90e8\u7c7b\u4e0d\u518d\u6301\u6709\u5916\u90e8\u7c7b\u4e86\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc32FG\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h2>\u5b9e\u4f8b\uff1a\u5185\u5b58\u6cc4\u9732<\/h2>\n<p><strong>\u300c\u7b80\u4ecb\u300d<\/strong><\/p>\n<p>\u82e5\u5185\u90e8\u7c7b\u6301\u6709\u5916\u90e8\u7c7b\u7684\u5f15\u7528\uff0c\u5bf9\u5185\u90e8\u7c7b\u7684\u4f7f\u7528\u5f88\u591a\u65f6\uff0c\u4f1a\u5bfc\u81f4\u5916\u90e8\u7c7b\u6570\u76ee\u5f88\u591a\u3002\u6b64\u65f6\uff0c\u5c31\u7b97\u662f\u5916\u90e8\u7c7b\u7684\u6570\u636e\u6ca1\u6709\u88ab\u7528\u5230\uff0c\u5916\u90e8\u7c7b\u7684\u6570\u636e\u6240\u5360\u7a7a\u95f4\u4e5f\u4e0d\u4f1a\u88ab\u91ca\u653e\u3002<\/p>\n<p>\u672c\u5904\u5728\u5916\u90e8\u7c7b\u5b58\u653e\u5927\u91cf\u7684\u6570\u636e\u6765\u6a21\u62df\u3002<\/p>\n<p><strong>\u300c\u4ee3\u7801\u300d<\/strong><\/p>\n<pre><code>package org.example.a;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nclass Outer{\n    private int[] data;\n\n    public Outer(int size) {\n        this.data = new int[size];\n    }\n\n    class Innner{\n\n    }\n\n    Innner createInner() {\n        return new Innner();\n    }\n}\n\npublic class Demo {\n    public static void main(String[] args) {\n        List&lt;Object&gt; list = new ArrayList&lt;&gt;();\n        int counter = 0;\n        while (true) {\n            list.add(new Outer(100000).createInner());\n            System.out.println(counter++);\n        }\n    }\n}<\/code><\/pre>\n<p><strong>\u300c\u6d4b\u8bd5\u300d<\/strong><\/p>\n<p>\u53ef\u4ee5\u770b\u5230\uff1a\u8fd0\u884c\u4e86\u516b\u5343\u591a\u6b21\u7684\u65f6\u5019\u5c31\u5185\u5b58\u6ea2\u51fa\u4e86\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc32FH\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6211\u6362\u4e86\u4e00\u53f0 mac \u7535\u8111\uff0c4000 \u591a\u5c31\u5185\u5b58\u6ea2\u51fa\u4e86\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc32FI\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h2>\u4e0d\u4f1a\u5185\u5b58\u6cc4\u9732\u7684\u65b9\u6848<\/h2>\n<p><strong>\u300c\u7b80\u4ecb\u300d<\/strong><\/p>\n<p>\u5185\u90e8\u7c7b\u6539\u4e3a\u9759\u6001\u7684\u4e4b\u540e\uff0c\u5b83\u6240\u5f15\u7528\u7684\u5bf9\u8c61\u6216\u5c5e\u6027\u4e5f\u5fc5\u987b\u662f\u9759\u6001\u7684\uff0c\u6240\u4ee5\u9759\u6001\u5185\u90e8\u7c7b\u65e0\u6cd5\u83b7\u5f97\u5916\u90e8\u5bf9\u8c61\u7684\u5f15\u7528\uff0c\u53ea\u80fd\u4ece JVM \u7684 Method Area\uff08\u65b9\u6cd5\u533a\uff09\u83b7\u53d6\u5230 static \u7c7b\u578b\u7684\u5f15\u7528\u3002<\/p>\n<p><strong>\u300c\u4ee3\u7801\u300d<\/strong><\/p>\n<pre><code>package org.example.a;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nclass Outer{\n    private int[] data;\n\n    public Outer(int size) {\n        this.data = new int[size];\n    }\n\n    static class Inner {\n\n    }\n\n    Inner createInner() {\n        return new Inner();\n    }\n}\n\npublic class Demo {\n    public static void main(String[] args) {\n        List&lt;Object&gt; list = new ArrayList&lt;&gt;();\n        int counter = 0;\n        while (true) {\n            list.add(new Outer(100000).createInner());\n            System.out.println(counter++);\n        }\n    }\n}<\/code><\/pre>\n<p><strong>\u300c\u6d4b\u8bd5\u300d<\/strong><\/p>\n<p>\u53ef\u4ee5\u53d1\u73b0\uff1a\u5faa\u73af\u4e86\u56db\u5341\u591a\u4e07\u6b21\u90fd\u6ca1\u6709\u5185\u5b58\u6ea2\u51fa\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc32FJ\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p><strong>\u8fd1\u671f\u70ed\u6587\u63a8\u8350\uff1a<\/strong><\/p>\n<p>1.<a href=\"https:\/\/link.segmentfault.com\/?enc=vhnwAlq1g32K21SGiXvXxA%3D%3D.hgMfiTs3HkJcotFsbDc22pPfbsVU4NutuPj3WHFC778%3D\" rel=\"nofollow\">1,000+ \u9053 Java\u9762\u8bd5\u9898\u53ca\u7b54\u6848\u6574\u7406(2022\u6700\u65b0\u7248)<\/a><\/p>\n<p>2.<a href=\"https:\/\/link.segmentfault.com\/?enc=0EAMhU4VDkq2lXrFELYIXA%3D%3D.1zdRvO0k2EyIIbIltT0A8kyI%2B7Jrirw1oFyqLxbbd0d%2FAm1D%2Fqs71gN0mAPLTq%2BluDBEmoU4xCBKJ3zKNCHJDw%3D%3D\" rel=\"nofollow\">\u52b2\u7206\uff01Java \u534f\u7a0b\u8981\u6765\u4e86\u3002\u3002\u3002<\/a><\/p>\n<p>3.<a href=\"https:\/\/link.segmentfault.com\/?enc=n32sWno2yr%2FTlGiSTYYmug%3D%3D.pZl%2FpDP5vo%2BqzSMKKIfh1ZOnM8WHOqusoHF32q5e4fMSqw%2FTtrP18USsu30aVlbA\" rel=\"nofollow\">Spring Boot 2.x \u6559\u7a0b\uff0c\u592a\u5168\u4e86\uff01<\/a><\/p>\n<p>4.<a href=\"https:\/\/link.segmentfault.com\/?enc=0ErFHYsk%2FVW9irzTsw2v7A%3D%3D.QRUkv8dZWq4AF8hzu8mCPJ2IfAdxWBKuREqOqaaOH9L%2Bcx1SeQz77mfn9t0L55mCDXaUyVNUQok2vdMbzpNwzA%3D%3D\" rel=\"nofollow\">\u522b\u518d\u5199\u6ee1\u5c4f\u7684\u7206\u7206\u7206\u70b8\u7c7b\u4e86\uff0c\u8bd5\u8bd5\u88c5\u9970\u5668\u6a21\u5f0f\uff0c\u8fd9\u624d\u662f\u4f18\u96c5\u7684\u65b9\u5f0f\uff01\uff01<\/a><\/p>\n<p>5.<a href=\"https:\/\/link.segmentfault.com\/?enc=xZhzNTnq1l2Q29bvLFzCug%3D%3D.UqhQkVxZslkGd6OAHOoyZlnLIh0uu1Ru0e9fRw3f%2Bmt%2FajsaXZcOkyfmCxMXglsvObt9HhkRZi8Ief2KPeVsbABVjHCsWukuek0%2BHnrNIFQ%3D\" rel=\"nofollow\">\u300aJava\u5f00\u53d1\u624b\u518c\uff08\u5d69\u5c71\u7248\uff09\u300b\u6700\u65b0\u53d1\u5e03\uff0c\u901f\u901f\u4e0b\u8f7d\uff01<\/a><\/p>\n<p>\u89c9\u5f97\u4e0d\u9519\uff0c\u522b\u5fd8\u4e86\u968f\u624b\u70b9\u8d5e+\u8f6c\u53d1\u54e6\uff01<\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000042870246\">https:\/\/segmentfault.com\/a\/1190000042870246<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6765\u6e90\uff1ahttps:\/\/knife.blog.csdn.net\/a&#8230; \u4eca\u5929\u7ed9\u5927\u5bb6\u5206\u4eab\u4e00\u79cd\uff0cJava\u5185 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10006899","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006899","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10006899"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006899\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10006899"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10006899"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10006899"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}