{"id":4221,"date":"2019-05-08T18:42:57","date_gmt":"2019-05-08T10:42:57","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=4221"},"modified":"2019-05-08T18:42:57","modified_gmt":"2019-05-08T10:42:57","slug":"3%e4%b8%aa%e7%a8%8b%e5%ba%8f%e5%91%98%e9%83%bd%e6%b2%a1%e8%a7%a3%e5%86%b3%e6%8e%89%e7%9a%84%e4%b8%80%e4%b8%aa%e5%8c%85%e8%a3%85%e7%b1%bb%e5%9e%8b%e5%92%8c%e9%9d%9e%e5%8c%85%e8%a3%85%e7%b1%bb%e5%9e%8b","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=4221","title":{"rendered":"3\u4e2a\u7a0b\u5e8f\u5458\u90fd\u6ca1\u89e3\u51b3\u6389\u7684\u4e00\u4e2a\u5305\u88c5\u7c7b\u578b\u548c\u975e\u5305\u88c5\u7c7b\u578b\u7684NULL\u5f02\u5e38"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u8ba9\u5f00\uff0c\u6211\u8981\u5f00\u59cb\u88c5\u903c\u4e86\u3002\u56e0\u4e3a 3 \u4e2a\u7a0b\u5e8f\u5458\u90fd\u6ca1\u89e3\u51b3\u6389\u7684\u4e00\u4e2a null \u5f02\u5e38\uff0c\u88ab\u6211\u8fd9\u4e2a\u7b2c\u56db\u4e2a\u7a0b\u5e8f\u5458\u89e3\u51b3\u4e86\u3002\u5c31\u95ee\u4f60\u4eec\u670d\u4e0d\u670d\uff0c\u6211\u80fd\u89e3\u51b3\u7a7a\u5f02\u5e38\u3002\u3002\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e8b\u60c5\u7684\u8d77\u56e0\u662f\u8fd9\u6837\u7684\uff0c\u7535\u5546\u7cfb\u7edf\u65b0\u7248\u672c\u589e\u52a0\u4e86\u4e00\u4e2a\u5c0f\u529f\u80fd\u3002\u5728\u53d1\u8d27\u6a21\u5757\u6709\u4e00\u4e2a\u5c0f\u9700\u6c42\u8981\u6539\u52a8\uff0c\u7a0b\u5e8f\u5458 A \u66f4\u6539\u4e86\u5176\u4e2d\u7684\u4e00\u4e2a\u65b9\u6cd5\u3002\u7136\u540e\u653e\u5728\u6d4b\u8bd5\u73af\u5883\u8fdb\u884c\u6d4b\u8bd5\u3002\u8fd9\u4e2a\u65b9\u6cd5\u65f6\u800c\u62a5 NULL \u5f02\u5e38\uff0c\u65f6\u800c\u53c8\u6b63\u5e38\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ed6\u6392\u67e5\u4e86\u534a\u5929\uff0c\u6ca1\u641e\u5b9a\u3002\u7136\u540e\u4f9d\u6258\u7a0b\u5e8f\u5458 B \u524d\u6765\u89e3\u51b3\uff0c\u7a0b\u5e8f\u5458 B \u770b\u4e86\u534a\u5929\uff0c\u6ca1\u53d1\u73b0\u95ee\u9898\u3002\u53c8\u4f9d\u6258\u7a0b\u5e8f\u5458 C \u6765\u89e3\u51b3\uff0c\u540c\u6837\u7684\u5931\u8d25\u4e86\u3002\u53d1\u751f\u8f66\u7978\u7684\u4ee3\u7801\u7b80\u5316\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>try{\n    long status = 0L;\n    Long xttblog = null;\n    System.out.println(xttblog == status);\n}catch (Exception e){\n    e.printStackTrace();\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u89e3\u91ca\u4e00\u4e0b\uff0c\u5c31\u662f\u6709\u4e00\u4e2a\u4e3a 0 \u7684\u72b6\u6001\u53d8\u91cf status \u4e0e\u4e00\u4e2a\u6570\u636e\u5e93\u4e2d\u67e5\u8be2\u51fa\u6765\u7684\u72b6\u6001\u8fdb\u884c\u6bd4\u8f83\u3002\u5b9e\u9645\u4ee3\u7801\u4e2d\u52a0\u4e0a\u4e86\u5c42\u5c42\u7684\u5224\u65ad\uff0c!= null \u7684\u5224\u65ad\u975e\u5e38\u591a\u3002\u4f46\u662f\u4ed6\u4eec\u6ca1\u60f3\u5230\u5305\u88c5\u7c7b\u578b Long \u548c\u975e\u5305\u88c5\u7c7b\u578b long \u4f1a\u51fa\u73b0\u7a7a\u5f02\u5e38\u3002\u53e6\u5916\u4e00\u4e2a\u4ea7\u751f\u8fd9\u4e2a\u95ee\u9898\u7684\u539f\u56e0\u662f\uff0c\u4ed6\u4eec\u8ba4\u4e3a\u4ece\u6570\u636e\u5e93\u67e5\u8be2\u51fa\u6765\u7684\u90a3\u4e2a Long \u4e0d\u53ef\u80fd\u4e3a\u7a7a\u3002\u4f46\u5b9e\u9645\u4e0a\u7a0b\u5e8f\u5458\u5728\u6d4b\u8bd5\u8fc7\u7a0b\u4e2d\u5077\u4e86\u61d2\uff0c\u4e3a\u4e86\u4e0d\u5220\u6389\u6570\u636e\uff0c\u4ed6\u628a\u9700\u8981\u5220\u9664\u7684\u6570\u636e\u7684\u4e3b\u952e id \u6539\u4e3a\u5c0f\u4e8e 0 \u7684\u8d1f\u6570\uff0c\u6700\u7ec8\u5bfc\u81f4\u4e86\u4e00\u4e9b\u6570\u636e\u67e5\u8be2\u4e0d\u51fa\u6765\u3002\u800c\u8c03\u8bd5\u7684\u65f6\u5019\uff0c\u5168\u662f\u6b63\u5e38\uff0c\u4e00\u5230\u6d4b\u8bd5\u73af\u5883\uff0c\u6d4b\u8bd5\u4e00\u6d4b\u5c31\u7ffb\u8f66\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u9762\u8fd9\u4e2a\u4ee3\u7801\u4e3a\u4ec0\u4e48\u4f1a\u53d1\u751f\u7a7a\u5f02\u5e38\u5462\uff1f\u662f\u56e0\u4e3a\u5f53\u4e00\u4e2a\u5305\u88c5\u7c7b\u578b\u548c\u975e\u5305\u88c5\u7c7b\u578b\u8fdb\u884c == \u6bd4\u8f83\u65f6\uff0c\u4f1a\u8fdb\u884c\u62c6\u7bb1\u64cd\u4f5c\u3002\u6700\u7ec8\u4f1a\u8f6c\u5316\u6210\u975e\u5305\u88c5\u7c7b\u578b\u8fdb\u884c\u6bd4\u8f83\uff0c\u800c\u503c\u4e3a null \u7684\u5305\u88c5\u7c7b\u578b Long \u5728\u8f6c\u6362\u8fc7\u7a0b\u4e2d\u65e0\u6cd5\u6b63\u5e38\u8f6c\u6362\u5c31\u56de\u8dd1\u51fa NULL \u5f02\u5e38\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1g2u3fvynadj20cd04vq3j.jpg\" alt=\"\" \/><figcaption>\u8f66\u7978\u4ee3\u7801<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e00\u70b9\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u4ece Long \u91cd\u5199\u7684 equals \u65b9\u6cd5\u4e0a\u770b\u51fa\u95ee\u9898\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public boolean equals(Object obj) {\n    if (obj instanceof Long) {\n        return value == ((Long)obj).longValue();\n    }\n    return false;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u800c\u5b9e\u9645\u4e0a\uff0c\u5728\u300a\u963f\u91cc\u5df4\u5df4Java \u5f00\u53d1\u624b\u518c\u300b\u4e2d\uff0c\u5df2\u7ecf\u6709\u4e86\u660e\u786e\u7684\u5f3a\u5236\u6027\u8981\u6c42\u4e86\u3002\u867d\u7136\u8bf4\u548c\u6211\u4eec\u8fd9\u4e00\u4e2a\u6709\u4e9b\u5dee\u5f02\uff0c\u4f46\u4e5f\u662f\u4e5f\u53ef\u4ee5\u501f\u9274\u7684\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1g2u3hgyr9jj20p8092403.jpg\" alt=\"\" \/><figcaption>\u300a\u963f\u91cc\u5df4\u5df4Java \u5f00\u53d1\u624b\u518c\u300b<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u540e\uff0c\u4e00\u5b9a\u8981\u6ce8\u610f\u3002\u7528==\u6bd4\u8f83\u5305\u88c5\u7c7b\u578b\u548c\u975e\u5305\u88c5\u7c7b\u578b\u7684\u65f6\u5019\uff0c\u5305\u88c5\u7c7b\u578b\u5bf9\u8c61\u88ab\u62c6\u7bb1\uff08\u8f6c\u4e3a\u975e\u5305\u88c5\u7684\u57fa\u672c\u7c7b\u578b\uff09\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=4221\">3\u4e2a\u7a0b\u5e8f\u5458\u90fd\u6ca1\u89e3\u51b3\u6389\u7684\u4e00\u4e2a\u5305\u88c5\u7c7b\u578b\u548c\u975e\u5305\u88c5\u7c7b\u578b\u7684NULL\u5f02\u5e38<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u8ba9\u5f00\uff0c\u6211\u8981\u5f00\u59cb\u88c5\u903c\u4e86\u3002\u56e0\u4e3a 3 \u4e2a\u7a0b\u5e8f\u5458\u90fd\u6ca1\u89e3\u51b3\u6389\u7684\u4e00\u4e2a null \u5f02\u5e38\uff0c\u88ab\u6211\u8fd9\u4e2a\u7b2c\u56db\u4e2a\u7a0b\u5e8f\u5458\u89e3\u51b3\u4e86\u3002\u5c31\u95ee\u4f60\u4eec [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[645,266,601,414,946],"class_list":["post-4221","post","type-post","status-publish","format-standard","hentry","category-java","tag-gitbook","tag-java","tag-outofmemoryerror","tag-spring","tag-946"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4221","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4221"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4221\/revisions"}],"predecessor-version":[{"id":4222,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4221\/revisions\/4222"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4221"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}