{"id":64818,"date":"2025-05-03T14:35:31","date_gmt":"2025-05-03T06:35:31","guid":{"rendered":"https:\/\/fwq.ai\/blog\/64818\/"},"modified":"2025-05-03T14:35:31","modified_gmt":"2025-05-03T06:35:31","slug":"java-%e4%b8%ad-int%e3%80%81integer%e3%80%81double%e3%80%81double-%e7%ad%89%e5%80%bc%e6%af%94%e8%be%83%ef%bc%9a-%e8%bf%90%e7%ae%97%e7%ac%a6%e5%92%8c-equals-%e6%96%b9%e6%b3%95%e7%9a%84%e5%8c%ba-3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/64818\/","title":{"rendered":"Java \u4e2d int\u3001Integer\u3001double\u3001Double \u7b49\u503c\u6bd4\u8f83\uff1a== \u8fd0\u7b97\u7b26\u548c equals() \u65b9\u6cd5\u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173078318635276.jpg\" class=\"aligncenter\" title=\"Java \u4e2d int\u3001Integer\u3001double\u3001Double \u7b49\u503c\u6bd4\u8f83\uff1a== \u8fd0\u7b97\u7b26\u548c equals() \u65b9\u6cd5\u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f\u63d2\u56fe\" alt=\"Java \u4e2d int\u3001Integer\u3001double\u3001Double \u7b49\u503c\u6bd4\u8f83\uff1a== \u8fd0\u7b97\u7b26\u548c equals() \u65b9\u6cd5\u7684\u533a\u522b\u662f\u4ec0\u4e48\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5173\u4e8e int\u3001integer\u3001double\u3001double \u7b49\u503c\u7684\u6bd4\u8f83<\/strong><\/p>\n<p>\u5728 java \u4e2d\uff0c\u4e0d\u540c\u7c7b\u578b\u4e4b\u95f4\u8fdb\u884c\u6bd4\u8f83\u65f6\u9700\u8981\u8003\u8651\u57fa\u672c\u7c7b\u578b\u548c\u5305\u88c5\u7c7b\u4e4b\u95f4\u7684\u5dee\u5f02\u3002\u8ba9\u6211\u4eec\u63a2\u7a76\u4ee5\u4e0b\u793a\u4f8b\u4e2d\u51fa\u73b0\u7684\u6bd4\u8f83\u884c\u4e3a\uff1a<\/p>\n<pre>int a = 10;\nDouble b = 10.0;\ndouble c = 10;\nDouble d = 10.0;\nInteger e = 10;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>== \u8fd0\u7b97\u7b26\u7684\u884c\u4e3a<\/strong><\/p>\n<ul>\n<li> <strong>\u57fa\u672c\u7c7b\u578b:<\/strong> int \u548c double \u7b49\u57fa\u672c\u7c7b\u578b\u4f7f\u7528 == \u8fd0\u7b97\u7b26\u8fdb\u884c\u76f4\u63a5\u7684\u503c\u6bd4\u8f83\u3002\u56e0\u6b64\uff0ca == c \u4e3a true\uff0c\u56e0\u4e3a\u4e24\u8005\u90fd\u662f 10.<\/li>\n<li> <strong>\u5305\u88c5\u7c7b:<\/strong> integer \u548c double \u7b49\u5305\u88c5\u7c7b\u4ee3\u8868\u57fa\u672c\u7c7b\u578b\u7684\u503c\uff0c\u4f46\u5b83\u4eec\u662f\u5bf9\u8c61\u3002== \u8fd0\u7b97\u7b26\u7528\u4e8e\u6bd4\u8f83\u5bf9\u8c61\u7684\u5f15\u7528\uff0c\u56e0\u6b64 b == d \u4e3a false\uff0c\u5373\u4f7f\u5b83\u4eec\u90fd\u8868\u793a\u76f8\u540c\u7684\u503c\u3002<\/li>\n<\/ul>\n<p><strong>b == e \u7f16\u8bd1\u65f6\u51fa\u9519<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u7531\u4e8e integer \u548c double \u90fd\u662f\u6570\u5b57\u5305\u88c5\u7c7b\uff0c\u6240\u4ee5\u4e0d\u80fd\u76f4\u63a5\u7528 == \u6bd4\u8f83\u3002\u60a8\u53ea\u80fd\u4f7f\u7528 == \u6765\u6bd4\u8f83\u540c\u4e00\u4e2a\u5305\u88c5\u7c7b\u7684\u4e24\u4e2a\u5bf9\u8c61\u3002\u56e0\u6b64\uff0cb == e \u7f16\u8bd1\u65f6\u4f1a\u51fa\u9519\u3002<\/p>\n<p><strong>\u4f7f\u7528 equals() \u65b9\u6cd5\u8fdb\u884c\u503c\u6bd4\u8f83<\/strong><\/p>\n<p>\u5f53\u6bd4\u8f83\u5305\u88c5\u7c7b\u4e2d\u7684\u503c\u65f6\uff0c\u4f7f\u7528 equals() \u65b9\u6cd5\u6bd4 == \u8fd0\u7b97\u7b26\u66f4\u5408\u9002\u3002equals() \u6bd4\u8f83\u4e24\u4e2a\u5bf9\u8c61\u7684\u503c\uff0c\u800c\u4e0d\u662f\u5b83\u4eec\u7684\u5f15\u7528\u3002\u56e0\u6b64\uff0cb.equals(d) \u548c e.equals(a) \u90fd\u8fd4\u56de true\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fJava \u4e2d int\u3001Integer\u3001double\u3001Double \u7b49\u503c\u6bd4\u8f83\uff1a== \u8fd0\u7b97\u7b26\u548c equals() \u65b9\u6cd5\u7684\u662f\u4ec0\u4e48\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8IDCBABY\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5173\u4e8e int\u3001integer\u3001double\u3001double \u7b49\u503c\u7684\u6bd4\u8f83 \u5728 java \u4e2d\uff0c\u4e0d\u540c\u7c7b\u578b\u4e4b\u95f4\u8fdb\u884c\u6bd4\u8f83\u65f6\u9700\u8981\u8003\u8651\u57fa\u672c\u7c7b\u578b\u548c\u5305\u88c5\u7c7b\u4e4b\u95f4\u7684\u5dee\u5f02\u3002\u8ba9\u6211\u4eec\u63a2\u7a76\u4ee5\u4e0b\u793a\u4f8b\u4e2d\u51fa\u73b0\u7684\u6bd4\u8f83\u884c\u4e3a\uff1a int a = 10; Double b = 10.0; double c = 10; Double d = 10.0; Integer e = 10; \u767b\u5f55\u540e\u590d\u5236 == \u8fd0\u7b97\u7b26\u7684\u884c\u4e3a \u57fa\u672c\u7c7b\u578b: int \u548c double \u7b49\u57fa\u672c\u7c7b\u578b\u4f7f\u7528 == \u8fd0\u7b97\u7b26\u8fdb\u884c\u76f4\u63a5\u7684\u503c\u6bd4\u8f83\u3002\u56e0\u6b64\uff0ca == c \u4e3a true\uff0c\u56e0\u4e3a\u4e24\u8005\u90fd\u662f 10. \u5305\u88c5\u7c7b: integer \u548c double \u7b49\u5305\u88c5\u7c7b\u4ee3\u8868\u57fa\u672c\u7c7b\u578b\u7684\u503c\uff0c\u4f46\u5b83\u4eec\u662f\u5bf9\u8c61\u3002== \u8fd0\u7b97\u7b26\u7528\u4e8e\u6bd4\u8f83\u5bf9\u8c61\u7684\u5f15\u7528\uff0c\u56e0\u6b64 b == d \u4e3a false\uff0c\u5373\u4f7f\u5b83\u4eec\u90fd\u8868\u793a\u76f8\u540c\u7684\u503c\u3002 b == e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-64818","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/64818","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=64818"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/64818\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=64818"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=64818"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=64818"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}