{"id":203771,"date":"2025-05-22T13:17:36","date_gmt":"2025-05-22T05:17:36","guid":{"rendered":"https:\/\/server.hk\/cnblog\/203771\/"},"modified":"2025-05-22T13:17:36","modified_gmt":"2025-05-22T05:17:36","slug":"java-%e6%96%b9%e6%b3%95%e9%87%8d%e8%bd%bd%ef%bc%9aint-%e5%92%8c-integer-%e7%b1%bb%e5%9e%8b%e5%a6%82%e4%bd%95%e5%bd%b1%e5%93%8d%e6%96%b9%e6%b3%95%e5%ae%9a%e4%b9%89%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/203771\/","title":{"rendered":"Java \u65b9\u6cd5\u91cd\u8f7d\uff1aint \u548c Integer \u7c7b\u578b\u5982\u4f55\u5f71\u54cd\u65b9\u6cd5\u5b9a\u4e49\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Java \u65b9\u6cd5\u91cd\u8f7d\uff1aint \u548c Integer \u7c7b\u578b\u5982\u4f55\u5f71\u54cd\u65b9\u6cd5\u5b9a\u4e49\uff1f<\/h1>\n<p>\u7f16\u7a0b\u5e76\u4e0d\u662f\u4e00\u4e2a\u673a\u68b0\u6027\u7684\u5de5\u4f5c\uff0c\u800c\u662f\u9700\u8981\u6709\u601d\u8003\uff0c\u6709\u521b\u65b0\u7684\u5de5\u4f5c\uff0c\u8bed\u6cd5\u662f\u56fa\u5b9a\u7684\uff0c\u4f46\u89e3\u51b3\u95ee\u9898\u7684\u601d\u8def\u5219\u662f\u4f9d\u9760\u4eba\u7684\u601d\u7ef4\uff0c\u8fd9\u5c31\u9700\u8981\u6211\u4eec\u575a\u6301\u5b66\u4e60\u548c\u66f4\u65b0\u81ea\u5df1\u7684\u77e5\u8bc6\u3002\u4eca\u5929\u5c31\u6574\u7406\u5206\u4eab\u300aJava \u65b9\u6cd5\u91cd\u8f7d\uff1aint \u548c Integer \u7c7b\u578b\u5982\u4f55\u5f71\u54cd\u65b9\u6cd5\u5b9a\u4e49\uff1f\u300b\uff0c\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\uff0c\u5982\u679c\u4f60\u5bf9\u6587\u7ae0\u65b9\u9762\u7684\u77e5\u8bc6\u70b9\u611f\u5174\u8da3\uff0c\u5c31\u4e0d\u8981\u9519\u8fc7\uff0c\u5728\u8fd9\u53ef\u4ee5\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u52a9\u529b\u5f00\u53d1\u80fd\u529b\u7684\u63d0\u5347\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241123\/1732326169674133193221e.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u65b9\u6cd5\u91cd\u8f7d\u4e0e int\u3001Integer \u7c7b\u578b\u5173\u7cfb<\/strong><\/p>\n<p>\u5728\u5b66\u4e60\u4e2d\u9047\u5230\u4e00\u4e2a\u95ee\u9898\uff0c\u60f3\u77e5\u9053 <strong>public int add(int a, int b)<\/strong> \u548c <strong>public void add(Integer a, Integer b)<\/strong> \u8fd9\u4e24\u4e2a\u65b9\u6cd5\u4e4b\u95f4\u7684\u5173\u7cfb\u3002<\/p>\n<p>\u6839\u636e\u91cd\u8f7d\u7684\u6761\u4ef6\uff1a\u65b9\u6cd5\u540d\u76f8\u540c\u3001\u53c2\u6570\u7c7b\u578b\u4e0d\u540c\u6216\u4e2a\u6570\u4e0d\u540c\u3001\u8fd4\u56de\u7c7b\u578b\u53ef\u80fd\u4e0d\u540c\uff0c<strong>\u8fd9\u4e24\u4e2a\u65b9\u6cd5\u770b\u4f3c\u662f\u91cd\u8f7d<\/strong>\u3002<\/p>\n<p>\u7136\u800c\uff0c\u7531\u4e8e Integer \u662f int \u7684\u5c01\u88c5\u7c7b\u578b\uff0c\u5e76\u4e14\u5728\u8c03\u7528\u65b9\u6cd5\u65f6\uff0cJava \u4f1a\u4f18\u5148\u67e5\u627e\u57fa\u672c\u6570\u636e\u7c7b\u578b\uff0c\u5f53 <strong>public int add(int a, int b)<\/strong> \u548c <strong>public int add(Integer a, Integer b)<\/strong> \u540c\u65f6\u5b58\u5728\u65f6\uff0c\u4f1a\u8ba4\u4e3a\u5b83\u4eec\u662f <strong>\u76f8\u540c\u7684\u65b9\u6cd5<\/strong>\uff0c\u5373\u4f7f\u8fd4\u56de\u7c7b\u578b\u4e0d\u540c\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u5f53\u8fd4\u56de\u503c\u7c7b\u578b\u4e3a int \u65f6\uff0c\u7f16\u8bd1\u5668\u4f1a\u62a5\u9519\uff0c\u63d0\u793a\u8fd9\u4e24\u4e2a\u65b9\u6cd5\u65e0\u6cd5\u533a\u5206\u3002<\/p>\n<p>\u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300aJava \u65b9\u6cd5\u91cd\u8f7d\uff1aint \u548c Integer \u7c7b\u578b\u5982\u4f55\u5f71\u54cd\u65b9\u6cd5\u5b9a\u4e49\uff1f\u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03\u6587\u7ae0\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java \u65b9\u6cd5\u91cd\u8f7d\uff1aint \u548c &#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-203771","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/203771","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=203771"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/203771\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=203771"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=203771"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=203771"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}