{"id":114,"date":"2023-12-26T05:34:07","date_gmt":"2023-07-16T14:50:27","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/index.php\/2023\/11\/30\/%e5%a6%82%e4%bd%95%e5%9c%a8java%e4%b8%ad%e4%bd%bf%e7%94%a8%e8%bf%90%e7%ae%97%e7%ac%a6\/"},"modified":"2025-08-01T00:10:58","modified_gmt":"2025-07-31T16:10:58","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8java%e4%b8%ad%e4%bd%bf%e7%94%a8%e8%bf%90%e7%ae%97%e7%ac%a6","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e5%9c%a8java%e4%b8%ad%e4%bd%bf%e7%94%a8%e8%bf%90%e7%ae%97%e7%ac%a6\/","title":{"rendered":"Java\u8fd0\u7b97\u7b26\u8be6\u89e3\uff1a\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\u5e94\u7528"},"content":{"rendered":"<h3>\u7b80\u4ecb<\/h3>\n<p>\u8fd0\u7b97\u7b26\u7531\u4e00\u4e2a\u6216\u591a\u4e2a\u7b26\u53f7\u7ec4\u5408\u800c\u6210\uff0c\u4f8b\u5982\u8457\u540d\u7684\u7b97\u672f\u8fd0\u7b97\u7b26\u51cf\u53f7\uff08-\uff09\u548c\u52a0\u53f7\uff08+\uff09\uff0c\u6216\u8005\u66f4\u9ad8\u7ea7\u7684<code>instanceof<\/code>\u3002\u5f53\u4f60\u5c06\u8fd0\u7b97\u7b26\u5e94\u7528\u4e8e\u503c\u6216\u53d8\u91cf\u65f6\uff0c\u4f1a\u5f97\u5230\u4e00\u4e2a\u8fd0\u7b97\u7ed3\u679c\u3002\u8fd9\u4e9b\u8fd0\u7b97\u5728\u7f16\u7a0b\u4e2d\u662f\u57fa\u7840\u7684\uff0c\u56e0\u4e3a\u5b83\u4eec\u7684\u7ed3\u679c\u53ef\u4ee5\u88ab\u8d4b\u7ed9\u4e00\u4e2a\u53d8\u91cf\uff0c\u6216\u8005\u901a\u8fc7\u8fdb\u4e00\u6b65\u7684\u8ba1\u7b97\u76f4\u5230\u7a0b\u5e8f\u8fbe\u5230\u6700\u7ec8\u76ee\u6807\u3002<\/p>\n<p>\u5bf9\u4e8e\u672c\u6559\u7a0b\uff0c\u4f60\u5fc5\u987b\u719f\u6089\u64cd\u4f5c\u6570\uff0c\u5373\u88ab\u8fd0\u7b97\u7b26\u5e94\u7528\u7684\u503c\u6216\u53d8\u91cf\u3002\u6839\u636e\u64cd\u4f5c\u6570\u7684\u6570\u91cf\uff0c\u8fd0\u7b97\u7b26\u53ef\u4ee5\u5206\u4e3a\u4e09\u7ec4\u3002\u9996\u5148\uff0c\u5f53\u64cd\u4f5c\u4e2d\u53ea\u6709\u4e00\u4e2a\u64cd\u4f5c\u6570\u65f6\uff0c\u8fd0\u7b97\u7b26\u88ab\u79f0\u4e3a\u4e00\u5143\u8fd0\u7b97\u7b26\u3002\u540c\u6837\u5730\uff0c\u4e8c\u5143\u8fd0\u7b97\u7b26\u6d89\u53ca\u4e24\u4e2a\u64cd\u4f5c\u6570\u3002\u6700\u540e\uff0c\u5f53\u6709\u4e09\u4e2a\u64cd\u4f5c\u6570\u65f6\uff0c\u8fd0\u7b97\u7b26\u4e3a\u4e09\u5143\u8fd0\u7b97\u7b26\u3002\u6839\u636e\u8fd9\u79cd\u5206\u7c7b\uff0c\u672c\u6559\u7a0b\u9488\u5bf9\u6bcf\u79cd\u7c7b\u578b\u7684\u8fd0\u7b97\u7b26\u5206\u4e3a\u4e09\u4e2a\u4e3b\u8981\u90e8\u5206\u8fdb\u884c\u7ec4\u7ec7\u3002<\/p>\n<p>\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u60a8\u5c06\u4f7f\u7528\u4e09\u79cd\u7c7b\u578b\u7684\u8fd0\u7b97\u7b26\u6765\u64cd\u4f5c\u539f\u59cb\u6570\u636e\u7c7b\u578b\uff0c\u4f8b\u5982\u6570\u5b66\u65b9\u7a0b\u3002\u60a8\u8fd8\u5c06\u5728\u66f4\u9ad8\u7ea7\u7684\u573a\u666f\u4e2d\u4f7f\u7528\u8fd0\u7b97\u7b26\u4e0e\u5f15\u7528\u7c7b\u578b\uff0c\u5e76\u63a2\u7d22\u4e00\u4e9b\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\u89c4\u5219\u3002<\/p>\n<h2>\u5148\u51b3\u6761\u4ef6<\/h2>\n<p>\u4e3a\u4e86\u8ddf\u968f\u672c\u6559\u7a0b\uff0c\u4f60\u9700\u8981\u51c6\u5907\uff1a<\/p>\n<ul class=\"post-ul\">\n<li>\u4e00\u4e2a\u53ef\u4ee5\u6267\u884cJava\u7a0b\u5e8f\u7684\u73af\u5883\uff0c\u4ee5\u4fbf\u8ddf\u968f\u793a\u4f8b\u3002\u8981\u5728\u672c\u5730\u673a\u5668\u4e0a\u8fdb\u884c\u8bbe\u7f6e\uff0c\u4f60\u9700\u8981\u5b89\u88c5Java\u5f00\u53d1\u5de5\u5177\u5305\uff08JDK\uff09\u63d0\u4f9b\u7684Java\uff08\u7248\u672c11\u6216\u66f4\u9ad8\u7248\u672c\uff09\u3002\u5bf9\u4e8eUbuntu\u548cDebian\uff0c\u8bf7\u9075\u5faa\u6211\u4eec\u6559\u7a0b\u300a\u5982\u4f55\u5728Ubuntu 22.04\u4e0a\u4f7f\u7528Apt\u5b89\u88c5Java\u300b\u4e2d\u9009\u98791\u7684\u6b65\u9aa4\u3002\u5bf9\u4e8e\u5305\u62ecMac\u548cWindows\u5728\u5185\u7684\u5176\u4ed6\u64cd\u4f5c\u7cfb\u7edf\uff0c\u8bf7\u53c2\u9605Java\u5b89\u88c5\u7684\u4e0b\u8f7d\u9009\u9879\u3002\u4e3a\u4e86\u7f16\u8bd1\u548c\u8fd0\u884c\u4ee3\u7801\u793a\u4f8b\uff0c\u672c\u6559\u7a0b\u4f7f\u7528Java Shell\uff0c\u5b83\u662f\u4e00\u4e2a\u4ece\u547d\u4ee4\u884c\u8fd0\u884c\u7684\u8bfb\u53d6-\u6c42\u503c-\u6253\u5370\u5faa\u73af\uff08REPL\uff09\u3002\u8981\u5f00\u59cb\u4f7f\u7528JShell\uff0c\u8bf7\u67e5\u9605\u300aJShell\u5165\u95e8\u6307\u5357\u300b\u3002<\/li>\n<li>\u719f\u6089Java\u548c\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\uff0c\u4f60\u53ef\u4ee5\u5728\u6211\u4eec\u7684\u6559\u7a0b\u300a\u5982\u4f55\u7f16\u5199\u4f60\u7684\u7b2c\u4e00\u4e2aJava\u7a0b\u5e8f\u300b\u4e2d\u627e\u5230\u76f8\u5173\u5185\u5bb9\u3002<\/li>\n<li>\u7406\u89e3Java\u6570\u636e\u7c7b\u578b\uff0c\u8fd9\u5728\u6211\u4eec\u7684\u6559\u7a0b\u300a\u7406\u89e3Java\u4e2d\u7684\u6570\u636e\u7c7b\u578b\u300b\u4e2d\u6709\u6240\u8ba8\u8bba\u3002<\/li>\n<\/ul>\n<h2>\u4e00\u5143\u8fd0\u7b97\u7b26<\/h2>\n<p>\u4e00\u5143\u8fd0\u7b97\u7b26\u5e94\u7528\u4e8e\u4e00\u4e2a\u64cd\u4f5c\u6570\uff0c\u8fd9\u4f7f\u5b83\u4eec\u53d8\u5f97\u6700\u76f4\u63a5\u3002\u4e00\u5143\u8fd0\u7b97\u7b26\u5e38\u88ab\u4f7f\u7528\uff0c\u56e0\u4e3a\u5b83\u4eec\u4f7f\u4ee3\u7801\u66f4\u7b80\u6d01\u3001\u6613\u8bfb\u3002\u5b83\u4eec\u4ee3\u66ff\u4e86\u660e\u786e\u63cf\u8ff0\u589e\u52a0\u548c\u51cf\u5c11\u503c\u7b49\u64cd\u4f5c\u7684\u9700\u8981\u3002\u7136\u800c\uff0c\u5f53\u4e0e\u5176\u4ed6\u8fd0\u7b97\u7b26\u7ed3\u5408\u65f6\uff0c\u4e00\u5143\u8fd0\u7b97\u7b26\u4e5f\u53ef\u80fd\u53d8\u5f97\u96be\u4ee5\u4f7f\u7528\uff0c\u7a0d\u540e\u5728\u672c\u8282\u4e2d\u60a8\u5c06\u53d1\u73b0\u8fd9\u4e00\u70b9\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u60a8\u5c06\u4f7f\u7528\u4e00\u5143\u8fd0\u7b97\u7b26\u6765\u589e\u52a0\u548c\u51cf\u5c11\u6570\u503c\uff0c\u4ee5\u53ca\u7ffb\u8f6c\u5e03\u5c14\u503c\u3002<\/p>\n<h3>\u9012\u589e\u548c\u9012\u51cf\u8fd0\u7b97\u7b26<\/h3>\n<p>\u589e\u91cf\u548c\u51cf\u91cf\u8fd0\u7b97\u7b26\uff0c\u6b63\u5982\u5b83\u4eec\u7684\u540d\u5b57\u6240\u8868\u660e\u7684\u90a3\u6837\uff0c\u7528\u4e8e\u589e\u52a0\u548c\u51cf\u5c11\u6570\u5b57\u3002\u589e\u91cf\u8fd0\u7b97\u7b26\u7531\u4e24\u4e2a\u52a0\u53f7\uff08<code>++<\/code>\uff09\u7ec4\u6210\uff0c\u800c\u51cf\u91cf\u8fd0\u7b97\u7b26\u7531\u4e24\u4e2a\u51cf\u53f7\uff08<code>--<\/code>\uff09\u7ec4\u6210\u3002\u8fd9\u4e9b\u8fd0\u7b97\u7b26\u5728\u64cd\u4f5c\u6570\u4e4b\u524d\u548c\u4e4b\u540e\u4f7f\u7528\u3002<\/p>\n<h4>\u524d\u589e\u91cf\u548c\u524d\u51cf\u91cf<\/h4>\n<p>\u5f53\u4f60\u5728\u64cd\u4f5c\u6570\u4e4b\u524d\u4f7f\u7528\u8fd0\u7b97\u7b26\u65f6\uff0c\u6839\u636e\u4f7f\u7528\u7684\u662f<code>++<\/code>\u8fd8\u662f<code>--<\/code>\uff0c\u4f60\u8fdb\u884c\u7684\u662f\u9884\u589e\u91cf\u6216\u9884\u51cf\u91cf\u64cd\u4f5c\u3002\u5f53\u4f60\u4f7f\u7528\u9884\u64cd\u4f5c\u7b26\u65f6\uff0c\u5728\u4f7f\u7528\u64cd\u4f5c\u6570\u4e4b\u524d\u4f60\u4f1a\u6539\u53d8\u5b83\u7684\u503c\u3002\u56e0\u6b64\uff0c\u5f53\u4f60\u5b9e\u9645\u4f7f\u7528\u8fd9\u4e2a\u503c\u65f6\uff0c\u5b83\u5df2\u7ecf\u53d1\u751f\u4e86\u6539\u53d8\u3002<\/p>\n<div class=\"post-conf-info\">\n<p class=\"post-conf-desc\">\u4fe1\u606f\uff1a\u8981\u6309\u7167\u672c\u6559\u7a0b\u4e2d\u7684\u793a\u4f8b\u4ee3\u7801\u64cd\u4f5c\uff0c\u8bf7\u5728\u672c\u5730\u7cfb\u7edf\u4e0a\u6253\u5f00Java Shell\u5de5\u5177\uff0c\u8fd0\u884c<code>jshell<\/code>\u547d\u4ee4\u3002\u7136\u540e\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u5728<code>jshell&gt;<\/code>\u63d0\u793a\u540e\u6dfb\u52a0\u5b83\u4eec\u5e76\u6309ENTER\u952e\u6765\u590d\u5236\u3001\u7c98\u8d34\u6216\u7f16\u8f91\u793a\u4f8b\u3002\u8981\u9000\u51fajshell\uff0c\u8f93\u5165<code>\/exit<\/code>\u3002\u8981\u4f7f\u7528\u524d\u589e\u91cf\u8fd0\u7b97\u7b26\uff0c\u5c06\u4ee5\u4e0b\u5185\u5bb9\u8f93\u5165\u5230jshell\u4e2d\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">int theAnswer <span class=\"token operator\">=<\/span> <span class=\"token number\">42<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">System.out.println<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#8220;Preincrementing: &#8220;<\/span> + <mark>++<\/mark>theAnswer<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u5728\u7b2c\u4e00\u884c\uff0c\u4f60\u7528\u503c\u4e3a42\u6765\u5b9a\u4e49\u4e00\u4e2a\u53d8\u91cf<code>theAnswer<\/code>\u3002\u5728\u7b2c\u4e8c\u884c\uff0c\u4f60\u4f7f\u7528<code>println()<\/code>\u65b9\u6cd5\u6765\u6253\u5370\u51fa\u5b83\uff0c\u5e76\u5c55\u793a\u5b83\u662f\u5982\u4f55\u6539\u53d8\u7684\u3002<\/p>\n<p>\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u524d\u7f00\u81ea\u589e\u8fd0\u7b97\u7b26\u662f<code>++<\/code>\uff0c\u5b83\u4f4d\u4e8e<code>theAnswer<\/code>\u4e4b\u524d\u3002\u901a\u8fc7\u4ee5\u8fd9\u79cd\u65b9\u5f0f\u4f7f\u7528\u524d\u7f00\u81ea\u589e\u8fd0\u7b97\u7b26\uff0c\u60a8\u9996\u5148\u5c06<code>theAnswer<\/code>\u7684\u503c\u589e\u52a0\u523043\u3002\u5728\u6b64\u4e4b\u540e\uff0c\u5f53<code>println()<\/code>\u5bf9\u5176\u8fdb\u884c\u5904\u7406\u65f6\uff0c\u5b83\u5df2\u7ecf\u662f43\uff0c\u56e0\u6b64\u60a8\u770b\u5230\u8f93\u51fa\u7684\u662f43\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">\u8f93\u51fa<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>theAnswer ==&gt; 42 Preincrementing: 43<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<\/div>\n<p>\u9884\u9012\u51cf\u5de5\u4f5c\u65b9\u5f0f\u7c7b\u4f3c\uff0c\u4f46\u60a8\u662f\u901a\u8fc7\u51cf\u5c11\u64cd\u4f5c\u6570\u7684\u503c\u6765\u9012\u51cf\u3002\u4f5c\u4e3a\u7ec3\u4e60\uff0c\u5c06\u4e0a\u8ff0\u793a\u4f8b\u4fee\u6539\u4e3a\u4f7f\u7528\u9884\u9012\u51cf\u8fd0\u7b97\u7b26<code>--<\/code>\u800c\u4e0d\u662f\u9884\u9012\u589e\u8fd0\u7b97\u7b26<code>++<\/code>\u3002<\/p>\n<h4>\u540e\u9012\u589e\u548c\u540e\u9012\u51cf<\/h4>\n<p>\u4e0e\u524d\u7f6e\u8fd0\u7b97\u7b26\u76f8\u6bd4\uff0c\u540e\u7f6e\u8fd0\u7b97\u7b26\u662f\u5728\u4f7f\u7528\u64cd\u4f5c\u6570\u540e\u66f4\u6539\u5176\u503c\u7684\u3002\u6709\u4e00\u4e9b\u7279\u5b9a\u60c5\u51b5\u4e0b\u5e38\u5e38\u4f7f\u7528\u540e\u7f6e\u6216\u524d\u7f6e\u8fd0\u7b97\u7b26\uff0c\u4f46\u6574\u4f53\u800c\u8a00\uff0c\u8fd9\u662f\u4e2a\u4eba\u504f\u597d\u7684\u95ee\u9898\u3002<\/p>\n<p>\u4e3a\u4e86\u6f14\u793a\u540e\u7f6e\u8fd0\u7b97\u7b26\u7684\u5de5\u4f5c\u539f\u7406\uff0c\u60a8\u5c06\u5bf9<code>theAnswer<\/code>\u7684\u503c\u8fdb\u884c\u540e\u589e\u64cd\u4f5c\uff0c\u5e76\u68c0\u67e5\u5176\u503c\u7684\u53d8\u5316\u3002\u5728jshell\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">int theAnswer <span class=\"token operator\">=<\/span> <span class=\"token number\">42<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">System.out.println<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#8220;Postincrementing: &#8220;<\/span> + theAnswer<mark>++<\/mark><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">System.out.println<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#8220;Final value: &#8220;<\/span> + theAnswer<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u53d8\u91cf<code>theAnswer<\/code>\u9996\u5148\u7b49\u4e8e42\u3002\u7136\u540e\uff0c\u5b83\u88ab\u6253\u5370\u51fa\u6765\u5e76\u8fdb\u884c\u540e\u81ea\u589e\u64cd\u4f5c\u3002\u5728\u6700\u540e\u4e00\u884c\uff0c\u4f60\u518d\u6b21\u6253\u5370\u5b83\u4ee5\u67e5\u770b\u6700\u7ec8\u503c\u3002<\/p>\n<p>\u4f60\u5e94\u8be5\u8f93\u51fa\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">\u8f93\u51fa<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>theAnswer ==&gt; 42 Postincrementing: 42 Final value: 43<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<\/div>\n<p>\u6b63\u5982\u4f60\u6240\u89c1\uff0c\u5728\u540e\u81ea\u589e\u7684\u8fc7\u7a0b\u4e2d\uff0c\u7b54\u6848\u4ecd\u7136\u662f42\u3002\u53ea\u6709\u5728\u540e\u81ea\u589e\u540e\u518d\u6b21\u6253\u5370\u65f6\uff0c\u7b54\u6848\u624d\u53d8\u6210\u4e8643\uff08\u6700\u7ec8\u503c\uff1a43\uff09\u3002<\/p>\n<p>\u540e\u9012\u51cf\u7684\u5de5\u4f5c\u65b9\u5f0f\u76f8\u540c\u3002\u9996\u5148\u83b7\u53d6\u5e76\u4f7f\u7528\u503c\uff0c\u7136\u540e\u624d\u8fdb\u884c\u9012\u51cf\u64cd\u4f5c\u3002\u4f5c\u4e3a\u7ec3\u4e60\uff0c\u8bf7\u5c1d\u8bd5\u5c06\u540e\u9012\u589e\u8fd0\u7b97\u7b26<code>++<\/code>\u66ff\u6362\u4e3a\u540e\u9012\u51cf\u8fd0\u7b97\u7b26<code>--<\/code>\uff0c\u751a\u81f3\u53ef\u4ee5\u5305\u542b\u5176\u4e2d\u4e00\u79cd\u524d\u8fd0\u7b97\u7b26\u3002<\/p>\n<h3>\u975e\u8fd0\u7b97\u7b26<\/h3>\n<p>\u8fd9\u662f\u6587\u7ae0\u300a\u5982\u4f55\u5728Java\u4e2d\u4f7f\u7528\u8fd0\u7b97\u7b26\u300b\u7684\u7b2c2\u90e8\u5206\uff08\u51718\u90e8\u5206\uff09\u3002<\/p>\n<p>\u5185\u5bb9\u7247\u6bb5\uff1a<\/p>\n<p>**\u903b\u8f91\u975e\u8fd0\u7b97\u7b26\uff08NOT\uff09**<\/p>\n<p>\u903b\u8f91\u975e\u8fd0\u7b97\u7b26\uff0c\u901a\u5e38\u7528\u611f\u53f9\u53f7 `!` \u8868\u793a\uff0c\u7528\u4e8e\u7ffb\u8f6c\u5e03\u5c14\u64cd\u4f5c\u6570\u7684\u503c\u3002\u5f53\u4f60\u6709\u4e00\u4e2a\u5e03\u5c14\u53d8\u91cf\u6216\u503c\uff0c\u5e76\u4e14\u5e0c\u671b\u4f7f\u7528\u5176\u76f8\u53cd\u7684\u503c\u65f6\uff0c`NOT` \u8fd0\u7b97\u7b26\u975e\u5e38\u6709\u7528\uff0c\u5b83\u907f\u514d\u4e86\u4e0d\u5fc5\u8981\u5730\u521b\u5efa\u53e6\u4e00\u4e2a\u5177\u6709\u76f8\u53cd\u503c\u7684\u53d8\u91cf\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a `NOT` \u8fd0\u7b97\u7b26\u7684\u5de5\u4f5c\u793a\u4f8b\u3002\u4e3a\u4e86\u7b80\u5316\u8bf4\u660e\uff0c\u6211\u4eec\u5c06\u53cd\u8f6c `true` \u7684\u503c\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">boolean isJavaFun <span class=\"token operator\">=<\/span> <mark><span class=\"token operator\">!<\/span><\/mark>true<span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">System.out.println<span class=\"token punctuation\">(<\/span>isJavaFun<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u4f60\u5b9a\u4e49\u4e86\u4e00\u4e2a\u5e03\u5c14\u53d8\u91cf `isJavaFun` \u4e3a `true`\u3002\u7136\u800c\uff0c`NOT` \u8fd0\u7b97\u7b26 `!` \u4f4d\u4e8e `true` \u4e4b\u524d\uff0c\u56e0\u6b64 `true` \u7684\u503c\u88ab\u7ffb\u8f6c\u4e3a `false`\u3002\u5f53\u4f60\u8fd0\u884c\u4e0a\u8ff0\u4ee3\u7801\u65f6\uff0c\u5c06\u6253\u5370\u4ee5\u4e0b\u8f93\u51fa\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">\u8f93\u51fa<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>isJavaFun ==> false<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<\/div>\n<p>\u8fd9\u5c31\u662f `NOT` \u8fd0\u7b97\u7b26\u7684\u5de5\u4f5c\u539f\u7406\u3002\u6709\u65f6\u5b83\u53ef\u80fd\u4f1a\u8ba9\u4eba\u611f\u5230\u56f0\u60d1\u4e14\u96be\u4ee5\u5bdf\u89c9\uff0c\u56e0\u6b64\u5728\u4f7f\u7528\u65f6\u5e94\u8c28\u614e\u3002<\/p>\n<p>\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u4f60\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528 `false` \u800c\u4e0d\u662f `!true`\u3002\u8fd9\u6837\u505a\u66f4\u6e05\u6670\u3001\u66f4\u76f4\u89c2\uff0c\u901a\u5e38\u662f\u66f4\u597d\u7684\u5b9e\u8df5\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u6700\u597d\u4f7f\u7528\u76f4\u63a5\u7684\u5b57\u9762\u91cf\u6216\u65b9\u6cd5\uff0c\u800c\u4e0d\u662f\u9700\u8981\u989d\u5916\u64cd\u4f5c\u7684\u66ff\u4ee3\u65b9\u6848\u3002\u7136\u800c\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u8fd9\u79cd\u505a\u6cd5\u53ef\u80fd\u5e76\u4e0d\u603b\u662f\u5408\u7406\u6216\u53ef\u884c\u3002\u4f8b\u5982\uff0c`NOT` \u8fd0\u7b97\u7b26\u901a\u5e38\u7528\u4e8e\u7ffb\u8f6c\u5e03\u5c14\u65b9\u6cd5\u7684\u7ed3\u679c\u3002<\/p>\n<p>\u4e3e\u4f8b\u6765\u8bf4\uff0c\u8981\u68c0\u67e5\u4e00\u4e2a\u5b57\u7b26\u4e32\u662f\u5426\u5305\u542b\u53e6\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 `contains()` \u65b9\u6cd5\u3002\u4f46\u662f\uff0c\u5982\u679c\u4f60\u60f3\u68c0\u67e5\u76f8\u53cd\u7684\u60c5\u51b5\uff08\u5373\u4e00\u4e2a\u5b57\u7b26\u4e32\u4e0d\u5305\u542b\u53e6\u4e00\u4e2a\u5b57\u7b26\u4e32\uff09\uff0c\u5219\u6ca1\u6709\u5176\u4ed6\u5185\u7f6e\u65b9\u6cd5\u53ef\u7528\u3002\u4f60\u9700\u8981\u5c06 `contains()` \u65b9\u6cd5\u4e0e `NOT` \u8fd0\u7b97\u7b26\u7ed3\u5408\u4f7f\u7528\u6765\u5b9e\u73b0\u3002<\/p>\n<p>\u5047\u8bbe\u4f60\u6709\u4e00\u4e2a\u5b57\u7b26\u4e32 \u201cJava is smart\u201d\uff0c\u5e76\u4e14\u4f60\u60f3\u68c0\u67e5\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u8be5\u5b57\u7b26\u4e32\u5305\u542b\u201c\u667a\u80fd\u201d\uff08smart\uff09\u3002<\/ol>\n<\/li>\n<\/ol>\n<ol>\u8be5\u5b57\u7b26\u4e32\u4e0d\u5305\u542b\u201c\u56f0\u96be\u201d\uff08hard\uff09\u3002<\/ol>\n<p>\u8981\u68c0\u67e5\u8fd9\u4e9b\uff0c\u4f60\u5c06\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">String javaIsSmart <span class=\"token operator\">=<\/span> <span class=\"token string\">&#8220;Java is smart.&#8221;<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">boolean isSmartPartOfJava <span class=\"token operator\">=<\/span> javaIsSmart.contains<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#8220;smart&#8221;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">boolean isHardNotPartOfJava <span class=\"token operator\">=<\/span> <mark><span class=\"token operator\">!<\/span><\/mark>javaIsSmart.contains<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#8220;hard&#8221;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u7b2c\u4e00\u884c\uff0c\u4f60\u5b9a\u4e49\u4e86\u4e00\u4e2a `String` \u53d8\u91cf `javaIsSmart`\u3002\u7b2c\u4e8c\u884c\uff0c\u4f60\u5b9a\u4e49\u4e86\u4e00\u4e2a\u5e03\u5c14\u53d8\u91cf `isSmartPartOfJava`\uff0c\u5b83\u7684\u503c\u7531 `contains()` \u65b9\u6cd5\u7684\u64cd\u4f5c\u7ed3\u679c\u51b3\u5b9a\u2014\u2014\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5373\u5b57\u7b26\u4e32 &#8220;smart&#8221; \u662f\u5426\u662f `javaIsSmart` \u5b57\u7b26\u4e32\u7684\u4e00\u90e8\u5206\u3002\u540c\u6837\u5730\uff0c\u5728\u7b2c\u4e09\u884c\uff0c\u4f60\u5b9a\u4e49\u4e86\u4e00\u4e2a\u5e03\u5c14\u53d8\u91cf `isHardNotPartOfJava`\uff0c\u5b83\u7684\u503c\u662f `true`\uff0c\u56e0\u4e3a\u5728 `javaIsSmart` \u4e2d\u627e\u4e0d\u5230 &#8220;hard&#8221;\u3002<\/p>\n<p>\u5f53\u4f60\u5728 `jshell` \u4e2d\u8fd0\u884c\u8fd9\u6bb5\u4ee3\u7801\u65f6\uff0c\u4f60\u5c06\u4f1a\u5f97\u5230\u4ee5\u4e0b\u8f93\u51fa\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">\u8f93\u51fa<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>javaIsSmart ==> &#8220;Java is smart.&#8221;<br \/>\nisSmartPartOfJava ==> true<br \/>\nisHardNotPartOfJava ==> true<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<\/div>\n<p>\u6839\u636e\u4e0a\u8ff0\u8f93\u51fa\uff1a<\/p>\n<ul class=\"post-ul\">\n<li>`isSmartPartOfJava` \u4e3a `true`\uff0c\u56e0\u4e3a\u5728 `javaIsSmart` \u4e2d\u627e\u5230\u4e86 &#8220;smart&#8221;\u3002<\/li>\n<li>`isHardNotPartOfJava` \u4e5f\u4e3a `true`\uff0c\u56e0\u4e3a\u5728 `javaIsSmart` \u4e2d\u6ca1\u6709\u627e\u5230 &#8220;hard&#8221;\u3002<\/li>\n<\/ul>\n<p>\u5728\u672c\u8282\u4e2d\uff0c\u4f60\u63a2\u7d22\u4e86\u4f7f\u7528\u4e00\u4e2a\u64cd\u4f5c\u6570\u8fdb\u884c\u81ea\u589e\u3001\u81ea\u51cf\u548c\u903b\u8f91\u975e\u64cd\u4f5c\u7b26\u3002\u5c3d\u7ba1\u8fd9\u4e9b\u64cd\u4f5c\u7b26\u53ea\u6709\u4e00\u4e2a\u64cd\u4f5c\u6570\uff0c\u4f46\u5b83\u4eec\u53ef\u80fd\u96be\u4ee5\u4f7f\u7528\uff0c\u6b63\u5982\u903b\u8f91\u975e\u64cd\u4f5c\u7b26\u6240\u793a\u3002\u5728\u4e0b\u4e00\u6b65\u4e2d\uff0c\u4f60\u5c06\u901a\u8fc7\u4f7f\u7528\u4e24\u4e2a\u64cd\u4f5c\u6570\u7684\u8fd0\u7b97\u7b26\u6765\u8fdb\u4e00\u6b65\u5de9\u56fa\u8fd9\u4e9b\u77e5\u8bc6\u3002<\/p>\n<h2>\u4e8c\u5143\u8fd0\u7b97\u7b26<\/h2>\n<p>\u4e8c\u5143\u8fd0\u7b97\u7b26\u4f5c\u7528\u4e8e\u4e24\u4e2a\u64cd\u4f5c\u6570\uff0c\u901a\u5e38\u4e0e\u7b97\u672f\u8fd0\u7b97\uff08\u4f8b\u5982\u52a0\u6cd5\u548c\u51cf\u6cd5\uff09\u76f8\u5173\u8054\u3002\u8fd8\u6709\u5176\u4ed6\u975e\u6570\u5b66\u76f8\u5173\u7684\u4e8c\u5143\u8fd0\u7b97\u7b26\uff0c\u4f8b\u5982\u903b\u8f91\u8fd0\u7b97\u7b26\u548c\u7279\u6b8a\u7684\u5173\u7cfb\u8fd0\u7b97\u7b26 `instanceof`\u3002\u5728\u672c\u8282\u4e2d\uff0c\u4f60\u5c06\u9996\u5148\u5b66\u4e60\u7b97\u672f\u4e8c\u5143\u8fd0\u7b97\u7b26\uff0c\u8fd9\u53ef\u80fd\u66f4\u4e3a\u719f\u6089\u3002<\/p>\n<h3>\u7b97\u672f\u4e8c\u5143\u8fd0\u7b97\u7b26<\/h3>\n<p>\u4ee5\u4e0b\u662f\u7528\u4e8e\u7b97\u672f\u8fd0\u7b97\u7684\u5e38\u89c1\u64cd\u4f5c\u7b26\uff0c\u5982\u52a0\u6cd5\uff08`+`\uff09\u548c\u51cf\u6cd5\uff08`-`\uff09\u3002\u4ee5\u4e0b\u662f\u52a0\u6cd5\u793a\u4f8b\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">int theAnswer <span class=\"token operator\">=<\/span> <span class=\"token number\">40<\/span> <mark>+<\/mark> <span class=\"token number\">2<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">System.out.println<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#8220;The result is: &#8220;<\/span> + theAnswer<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u5728\u7b2c\u4e00\u884c\uff0c\u4f60\u5c06 `2` \u52a0\u5230 `40` \u4e0a\uff0c\u5e76\u5c06\u7ed3\u679c\u8d4b\u503c\u7ed9 `theAnswer` \u53d8\u91cf\u3002\u5f53\u4f60\u6253\u5370\u5b83\u65f6\uff0c\u4f60\u5f97\u5230\u6700\u7ec8\u503c `42`\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">\u8f93\u51fa<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>The result is: 42<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<\/div>\n<div class=\"post-conf-note\">\n<p class=\"post-conf-desc\">**\u6ce8\u610f\uff1a**\u9664\u4e86\u7528\u4e8e\u7b97\u672f\u8fd0\u7b97\u5916\uff0c\u52a0\u53f7\uff08`+`\uff09\u8fd8\u7528\u4e8e\u8fde\u63a5\u5b57\u7b26\u4e32\u3002\u4f60\u5728\u6211\u4eec\u5c55\u793a\u6253\u5370\u503c\u7684\u5927\u591a\u6570\u4f8b\u5b50\u4e2d\u90fd\u89c1\u8fc7\u5b83\u7684\u4f5c\u7528\uff0c\u5c31\u50cf\u4e0a\u9762\u90a3\u4e2a\u4f8b\u5b50\u4e00\u6837\u3002\u5728\u90a3\u91cc\uff0c\u4f60\u4f7f\u7528\u52a0\u53f7\u628a\u201c\u7ed3\u679c\u662f\uff1a\u201d\u548c\u53d8\u91cf `theAnswer` \u8fde\u63a5\u8d77\u6765\u3002\u7136\u800c\uff0c\u8fd9\u79cd\u7528\u6cd5\u662f\u4e00\u4e2a\u4f8b\u5916\uff0c\u5176\u4ed6\u7b97\u672f\u8fd0\u7b97\u7b26\u4e0d\u80fd\u7528\u4e8e\u5f15\u7528\u7c7b\u578b\u3002\u6240\u4ee5\uff0c\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u4f60\u4e0d\u80fd\u4f7f\u7528\u51cf\u53f7\u6765\u5220\u9664\u5b57\u7b26\u4e32\u7684\u4e00\u90e8\u5206\u3002\u4e3a\u4e86\u8fdb\u4e00\u6b65\u7ec3\u4e60\uff0c\u5c1d\u8bd5\u4f7f\u7528\u5176\u4ed6\u7b97\u672f\u8fd0\u7b97\u7b26\uff0c\u4f60\u53ef\u4ee5\u5728Java\u6587\u6863\u4e2d\u627e\u5230\u3002<\/p>\n<\/div>\n<h3>\u8d4b\u503c\u8fd0\u7b97\u7b26<\/h3>\n<p>\u8d4b\u503c\u8fd0\u7b97\u7b26\u5c06\u53f3\u64cd\u4f5c\u6570\u7684\u503c\u8d4b\u7ed9\u5de6\u64cd\u4f5c\u6570\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u5de6\u64cd\u4f5c\u6570\u662f\u4e00\u4e2a\u53d8\u91cf\uff0c\u53f3\u64cd\u4f5c\u6570\u662f\u4e00\u4e2a\u503c\u6216\u6307\u5411\u5bf9\u8c61\u7684\u5f15\u7528\u3002\u8fd9\u53ef\u80fd\u542c\u8d77\u6765\u5f88\u719f\u6089\uff0c\u56e0\u4e3a\u4f60\u5728\u6240\u6709\u7684\u4f8b\u5b50\u4e2d\u90fd\u4f7f\u7528\u8fc7\u8fd9\u6837\u7684\u8d4b\u503c\u3002\u5728\u672c\u8282\u4e2d\uff0c\u4f60\u5c06\u7ec3\u4e60\u4f7f\u7528\u57fa\u672c\u7684\u8d4b\u503c\u8fd0\u7b97\u7b26\u3001\u4e00\u4e9b\u590d\u5408\u8d4b\u503c\u8fd0\u7b97\u7b26\u548c\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\u8fd0\u7b97\u7b26\u3002<\/p>\n<p>\u57fa\u672c\u7684\u8d4b\u503c\u8fd0\u7b97\u7b26\uff08`=`\uff09\u662f\u4e00\u4e2a\u4f17\u6240\u5468\u77e5\u4e14\u7ecf\u5e38\u4f7f\u7528\u7684\u8fd0\u7b97\u7b26\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">int x <mark><span class=\"token operator\">=<\/span><\/mark> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u4f60\u58f0\u660e\u4e00\u4e2a\u6574\u6570\u53d8\u91cf `x`\uff0c\u5e76\u8d4b\u503c\u4e3a `1`\u3002\u4f7f\u7528\u7b49\u53f7\uff08`=`\uff09\u662f\u7ed9\u53d8\u91cf\u8d4b\u503c\u7684\u65b9\u6cd5\u3002<\/p>\n<h4>\u590d\u5408\u8d4b\u503c\u8fd0\u7b97\u7b26<\/h4>\n<p>\u8fd9\u662f\u6587\u7ae0\u300a\u5982\u4f55\u5728Java\u4e2d\u4f7f\u7528\u8fd0\u7b97\u7b26\u300b\u7684\u7b2c3\u90e8\u5206\uff08\u51718\u90e8\u5206\uff09\u3002<\/p>\n<p><strong>\u590d\u5408\u8d4b\u503c\u8fd0\u7b97\u7b26<\/strong>\uff08<code>+=<\/code>\u3001<code>-=<\/code>\u3001<code>*=<\/code>\u3001<code>\/=<\/code>\uff09\u5c06\u8d4b\u503c\u4e0e\u9644\u52a0\u7684\u7b97\u672f\u8fd0\u7b97\uff08\u5982\u52a0\u6cd5\u6216\u51cf\u6cd5\uff09\u7ed3\u5408\u8d77\u6765\u3002\u8fd9\u4e9b\u8fd0\u7b97\u7b26\u53ef\u4ee5\u907f\u514d\u5197\u4f59\u4ee3\u7801\uff0c\u7279\u522b\u9002\u7528\u4e8e\u7b80\u5355\u6613\u61c2\u7684\u7b97\u672f\u8fd0\u7b97\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u4f7f\u7528\u590d\u5408 <code>+=<\/code> \u8d4b\u503c\u8fd0\u7b97\u7b26\u6765\u5c06\u52a0\u6cd5\u548c\u8d4b\u503c\u7ed3\u5408\u5728\u4e00\u8d77\uff0c\u5c31\u50cf\u8fd9\u6837:<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">int x <span class=\"token operator\">=<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">int y <span class=\"token operator\">=<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">x <mark><span class=\"token operator\">+=<\/span><\/mark> y<span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">System.out.println<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#8220;x is: &#8220;<\/span> + x<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u5728\u524d\u4e24\u884c\u4e2d\uff0c\u4f60\u58f0\u660e\u4e86\u4e24\u4e2a\u6574\u6570\u53d8\u91cf<code>x<\/code>\u548c<code>y<\/code>\uff0c\u5b83\u4eec\u7684\u503c\u90fd\u4e3a1\u3002\u63a5\u4e0b\u6765\uff0c\u4f60\u4f7f\u7528<code>+=<\/code>\u8fd0\u7b97\u7b26\u91cd\u65b0\u4e3a<code>x<\/code>\u8d4b\u503c\uff0c\u8fd9\u610f\u5473\u7740<code>x<\/code>\u5148\u4e0e<code>y<\/code>\u76f8\u52a0\uff0c\u7136\u540e\u518d\u8d4b\u503c\u7ed9<code>x<\/code>\u3002<\/p>\n<p>\u4ee5\u4e0a\u4ee3\u7801\u5c06\u8fd4\u56de\u7c7b\u4f3c\u4e8e\u8fd9\u6837\u7684\u8f93\u51fa\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">\u8f93\u51fa<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>x ==&gt; 1 y ==&gt; 1 $11 ==&gt; 2 x is: 2<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<\/div>\n<p>\u6839\u636e\u4e0a\u8ff0\u8f93\u51fa\uff0c<code>x<\/code>\u548c<code>y<\/code>\u7684\u503c\u90fd\u4e3a1\u3002\u5728\u7b2c\u4e09\u884c\uff0c\u6709\u4e00\u4e2a\u4e34\u65f6\u53d8\u91cf\uff0c\u5b83\u7684\u540d\u79f0\u662f\u968f\u673a\u5206\u914d\u7684(<code>$11<\/code>)\u3002\u5b83\u901a\u8fc7\u590d\u5408\u8d4b\u503c\u64cd\u4f5c\u4fdd\u5b58\u4e86<code>x<\/code>\u7684\u503c\u3002\u5728\u6700\u540e\u4e00\u884c\uff0c\u6253\u5370\u51fa\u7684<code>x<\/code>\u7684\u503c\u4e3a2\u3002<\/p>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u53ef\u4ee5\u4e0d\u4f7f\u7528\u590d\u5408\u8d4b\u503c\u8fd0\u7b97\u7b26\u8fdb\u884c\u91cd\u5199\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">int x <span class=\"token operator\">=<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">int y <span class=\"token operator\">=<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\"><mark>x <span class=\"token operator\">=<\/span> x + y<span class=\"token punctuation\">;<\/span><\/mark><\/li>\n<li data-prefix=\"jshell&gt;\">System.out.println<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#8220;x is: &#8220;<\/span> + x<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u4e0e\u4e4b\u524d\u7684\u4f8b\u5b50\u76f8\u6bd4\uff0c\u4f60\u9700\u8981\u5728\u7b2c3\u884c\u7f16\u5199\u989d\u5916\u7684\u4ee3\u7801\u6765\u660e\u786e\u63cf\u8ff0<code>x<\/code>\u52a0<code>y<\/code>\u7684\u76f8\u52a0\u8fc7\u7a0b\u3002<\/p>\n<p>\u8fd0\u884c\u8fd9\u6bb5\u4ee3\u7801\u5c06\u8fd4\u56de\u4ee5\u4e0b\u8f93\u51fa\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">\u8f93\u51fa<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>x ==&gt; 1 y ==&gt; 1 x ==&gt; 2 x is: 2<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<\/div>\n<p>\u6700\u7ec8\uff0c\u65e0\u8bba\u662f\u7b2c\u4e00\u4e2a\u8fd8\u662f\u7b2c\u4e8c\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>x<\/code>\u90fd\u7b49\u4e8e2\u3002\u7136\u800c\uff0c\u5728\u7b2c\u4e8c\u4e2a\u4f8b\u5b50\u4e2d\uff0cjshell \u6ca1\u6709\u6253\u5370\u4e00\u4e2a\u4e34\u65f6\u53d8\u91cf\u540d\u79f0\uff0c\u6bd4\u5982<code>$11<\/code>\u3002\u76f8\u53cd\uff0c\u5b83\u76f4\u63a5\u4f7f\u7528\u4e86<code>x<\/code>\u6765\u663e\u793a\u5b83\u7684\u503c\u5df2\u7ecf\u6539\u53d8\uff08<code>x ==&gt; 2<\/code>\uff09\u3002\u8fd9\u6837\u8be6\u7ec6\u7684\u8f93\u51fa\u5bf9\u5b66\u4e60\u975e\u5e38\u6709\u5e2e\u52a9\uff0c\u800c\u4e14\u53ea\u6709\u5728jshell\u4e2d\u624d\u80fd\u4f7f\u7528\u3002<\/p>\n<p>\u5176\u4f59\u7684\u590d\u5408\u8fd0\u7b97\u7b26\u5305\u62ec\u51cf\u6cd5\uff08<code>-=<\/code>\uff09\u3001\u4e58\u6cd5\uff08<code>*=<\/code>\uff09\u548c\u9664\u6cd5\uff08<code>\/=<\/code>\uff09\uff0c\u4e0e\u8d4b\u503c\u4e00\u8d77\u7ed3\u5408\u4f7f\u7528\u3002\u5c1d\u8bd5\u66f4\u6539\u4e0a\u8ff0\u793a\u4f8b\u6765\u67e5\u770b\u5b83\u4eec\u7684\u5de5\u4f5c\u65b9\u5f0f\u3002<\/p>\n<p>\u4e86\u89e3\u590d\u5408\u8fd0\u7b97\u7b26\u662f\u5f88\u597d\u7684\uff0c\u56e0\u4e3a\u5b83\u4eec\u7ecf\u5e38\u88ab\u4f7f\u7528\u3002\u7136\u800c\uff0c\u4f7f\u7528\u590d\u5408\u8fd0\u7b97\u7b26\u5e76\u4e0d\u4f1a\u63d0\u9ad8\u6027\u80fd\uff0c\u56e0\u6b64\u4f7f\u7528\u590d\u5408\u8fd0\u7b97\u7b26\u662f\u4e2a\u4eba\u9009\u62e9\u7684\u95ee\u9898\u3002\u5982\u679c\u5b83\u4eec\u770b\u8d77\u6765\u4ee4\u4eba\u56f0\u60d1\uff0c\u5219\u53ef\u4ee5\u9009\u62e9\u4e0d\u4f7f\u7528\u3002<\/p>\n<h4>\u8f6c\u578b\u8fd0\u7b97\u7b26<\/h4>\n<p>\u4f60\u5c06\u8981\u56de\u987e\u7684\u6700\u540e\u4e00\u4e2a\u8d4b\u503c\u64cd\u4f5c\u7b26\u662f<strong>\u8f6c\u578b\u64cd\u4f5c\u7b26<\/strong>\uff0c\u5b83\u662f\u4e00\u4e2a\u7531\u62ec\u53f7\u62ec\u8d77\u6765\u7684\u6570\u636e\u7c7b\u578b\uff1a<code>(\u6570\u636e\u7c7b\u578b)<\/code>\u3002\u8f6c\u578b\u64cd\u4f5c\u7b26\u7528\u4e8e\u7c7b\u578b\u8f6c\u6362\uff0c\u5373\u5c06\u4e00\u4e2a\u6570\u636e\u7c7b\u578b\u89e3\u91ca\u4e3a\u53e6\u4e00\u4e2a\u6570\u636e\u7c7b\u578b\u3002<\/p>\n<p>\u6570\u636e\u7c7b\u578b\u5fc5\u987b\u662f\u517c\u5bb9\u7684\u3002\u6570\u636e\u7c7b\u578b\u4e4b\u95f4\u662f\u5426\u517c\u5bb9\u53d6\u51b3\u4e8e\u5b83\u4eec\u4e4b\u95f4\u7684\u5173\u7cfb\uff0c\u6bd4\u5982\u4e00\u4e2a\u7c7b\u662f\u5426\u662f\u53e6\u4e00\u4e2a\u7c7b\u7684\u7236\u7c7b\u6216\u540c\u7ea7\u7c7b\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u5c06\u6574\u6570\u8f6c\u6362\u4e3a\u77ed\u6574\u578b\uff0c\u56e0\u4e3a\u8fd9\u4e24\u79cd\u6570\u636e\u7c7b\u578b\u90fd\u7528\u4e8e\u5b58\u50a8\u6574\u6570\u3002\u7136\u800c\uff0c\u4f60\u4e0d\u80fd\u5c06\u6574\u6570\u8f6c\u6362\u4e3a\u5e03\u5c14\u578b\uff0c\u56e0\u4e3a\u8fd9\u4e24\u79cd\u6570\u636e\u7c7b\u578b\u4e0d\u517c\u5bb9\u3002<\/p>\n<p>\u5728\u8fd9\u4e00\u8282\u4e2d\uff0c\u4f60\u5c06\u63a2\u7d22\u4e00\u4e9b\u5e38\u89c1\u7684\u7c7b\u578b\u8f6c\u6362\u793a\u4f8b\u548c\u95ee\u9898\u3002\u4e3a\u4e86\u6559\u80b2\u76ee\u7684\uff0c\u4f60\u5c06\u4ece\u4e00\u4e2a\u9519\u8bef\u548c\u4e0d\u5339\u914d\u7684\u8f6c\u6362\u5f00\u59cb\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">boolean y <span class=\"token operator\">=<\/span> <mark><span class=\"token punctuation\">(<\/span>boolean<span class=\"token punctuation\">)<\/span><\/mark> <span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u4f7f\u7528\u8fd9\u884c\u4ee3\u7801\uff0c\u4f60\u8bd5\u56fe\u5c06\u6574\u65701\u8f6c\u6362\u4e3a\u5e03\u5c14\u503c\uff0c\u5e76\u8d4b\u503c\u7ed9\u53d8\u91cf<code>y<\/code>\u3002\u5f53\u4f60\u5c06\u5176\u7c98\u8d34\u5230JShell\u4e2d\u65f6\uff0c\u4f60\u4f1a\u5f97\u5230\u4ee5\u4e0b\u9519\u8bef\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">\u8f93\u51fa<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>| Error: | incompatible types: int cannot be converted to boolean |<br \/>\n| boolean y = (boolean) 1; |<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<\/div>\n<p>\u6839\u636e\u9519\u8bef\u4fe1\u606f\u6240\u8ff0\uff0c\u4f60\u4e0d\u80fd\u5c06\u4e00\u4e2a\u6574\u6570\u503c\u8f6c\u6362\u4e3a\u5e03\u5c14\u503c\u3002\u5e03\u5c14\u503c\u53ea\u80fd\u662f<code>true<\/code>\u6216<code>false<\/code>\uff0c\u65e0\u6cd5\u786e\u5b9a1\u5e94\u8be5\u662f\u54ea\u4e2a\u5e03\u5c14\u503c\u3002<\/p>\n<p>\u73b0\u5728\uff0c\u4f60\u5c06\u5c1d\u8bd5\u4e00\u4e2a\u5177\u6709\u517c\u5bb9\u6570\u636e\u7c7b\u578b\u7684\u4f8b\u5b50\u3002\u4f60\u5c06\u4f7f\u7528\u4e24\u79cd\u539f\u59cb\u7c7b\u578b\u6765\u5b58\u50a8\u6574\u6570\uff1a<code>int<\/code> \u548c <code>short<\/code>\u3002\u5b83\u4eec\u7684\u533a\u522b\u5728\u4e8e\u5b83\u4eec\u7684\u5bb9\u91cf\uff0c\u4e5f\u5c31\u662f\u5b58\u50a8\u4fe1\u606f\u53ef\u7528\u7684\u5185\u5b58\u91cf\u3002<code>int<\/code>\u5177\u6709\u66f4\u5927\u7684\u5bb9\u91cf\uff0c\u56e0\u6b64\u53ef\u4ee5\u5b58\u50a8\u66f4\u5927\u7684\u6570\u5b57\u3002<\/p>\n<p>\u5c06\u4ee5\u4e0b\u884c\u6dfb\u52a0\u5230jshell\u4e2d\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">int prize <span class=\"token operator\">=<\/span> <span class=\"token number\">32767<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">short wonPrize <span class=\"token operator\">=<\/span> <mark><span class=\"token punctuation\">(<\/span>short<span class=\"token punctuation\">)<\/span><\/mark> prize<span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">System.out.println<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#8220;You won: &#8220;<\/span> + wonPrize<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u5728\u7b2c\u4e00\u884c\u4e2d\uff0c\u4f60\u5c06\u5f69\u7968\u5956\u54c1\u5b9a\u4e49\u4e3a\u4e00\u4e2a\u503c\u4e3a32767\u7684<code>int<\/code>\u539f\u59cb\u7c7b\u578b\u3002\u7136\u800c\uff0c\u5728\u7b2c\u4e8c\u884c\u4e2d\uff0c\u4f60\u51b3\u5b9a\u4f7f\u7528<code>short<\/code>\u539f\u59cb\u7c7b\u578b\u66f4\u5408\u9002\u6765\u50a8\u5b58<code>wonPrize<\/code>\u7684\u503c\uff0c\u5e76\u4f7f\u7528<code>(short)<\/code>\u5c06<code>prize<\/code>\u8f6c\u6362\u4e3a<code>short<\/code>\u7c7b\u578b\u3002<\/p>\n<p>\u5728jshell\u4e2d\u8fd0\u884c\u4e0a\u8ff0\u4ee3\u7801\u65f6\uff0c\u8f93\u51fa\u7ed3\u679c\u662f\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">\u8f93\u51fa<\/div>\n<p>\u8fd9\u662f\u6587\u7ae0\u300a\u5982\u4f55\u5728Java\u4e2d\u4f7f\u7528\u8fd0\u7b97\u7b26\u300b\u7684\u7b2c4\u90e8\u5206\uff08\u51718\u90e8\u5206\uff09\u3002<\/p>\n<pre class=\"post-pre\"><code>prize ==&gt; 32767\r\nwonPrize ==&gt; 32767\r\nYou won: 32767<\/code><\/pre>\n<p>\u4e0a\u9762\u7684\u8f93\u51fa\u786e\u8ba4\u4e86\u5956\u54c1\uff08<code>prize<\/code>\uff09\u548c\u8d62\u5f97\u5956\u54c1\uff08<code>wonPrize<\/code>\uff09\u7684\u503c\u90fd\u88ab\u6b63\u786e\u8bbe\u7f6e\u4e3a32767\u3002\u6700\u540e\u4e00\u884c\u4f7f\u7528<code>wonPrize<\/code>\u53d8\u91cf\u6765\u663e\u793a\u60a8\u8d62\u5f97\u4e86\u591a\u5c11\u5956\u54c1\u3002<\/p>\n<p>\u5c31<code>int<\/code>\u548c<code>short<\/code>\u800c\u8a00\uff0c\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\u53ef\u80fd\u663e\u5f97\u6ca1\u6709\u5fc5\u8981\uff0c\u5b9e\u9645\u60c5\u51b5\u4e0b\u53ef\u80fd\u4e0d\u4f1a\u770b\u5230\u8fd9\u79cd\u8f6c\u6362\u3002\u7136\u800c\uff0c\u8fd9\u4e2a\u4f8b\u5b50\u5bf9\u4e8e\u5c55\u793a\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\u7684\u6982\u5ff5\u662f\u6709\u7528\u7684\u3002<\/p>\n<p>\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\u4f3c\u4e4e\u5f88\u7b80\u5355\uff0c\u4f46\u6709\u4e00\u4e2a\u6ce8\u610f\u4e8b\u9879\u3002\u5f53\u60a8\u4ece\u5177\u6709\u8f83\u5927\u5bb9\u91cf\u7684\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u4e3a\u5177\u6709\u8f83\u5c0f\u5bb9\u91cf\u7684\u6570\u636e\u7c7b\u578b\u65f6\uff0c\u53ef\u80fd\u4f1a\u8d85\u8fc7\u8f83\u5c0f\u5bb9\u91cf\u7684\u9650\u5236\uff0c\u8fd9\u88ab\u79f0\u4e3a\u6ea2\u51fa\u3002\u4e3a\u4e86\u5c55\u793a\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u91cd\u7528\u4e4b\u524d\u7684\u4f8b\u5b50\uff0c\u5e76\u5c06\u5956\u52b1\u4ece32767\u589e\u52a0\u523032768\uff0c\u50cf\u8fd9\u6837\uff1a<\/p>\n<pre class=\"post-pre\"><ol>\r\n \t<li data-prefix=\"jshell&gt;\">int prize <span class=\"token operator\">=<\/span> <span class=\"token number\">32768<\/span><span class=\"token punctuation\">;<\/span><\/li>\r\n \t<li data-prefix=\"jshell&gt;\">short wonPrize <span class=\"token operator\">=<\/span> <span class=\"token punctuation\">(<\/span>short<span class=\"token punctuation\">)<\/span> prize<span class=\"token punctuation\">;<\/span><\/li>\r\n \t<li data-prefix=\"jshell&gt;\">System.out.println<span class=\"token punctuation\">(<\/span><span class=\"token string\">\"You won: \"<\/span> + wonPrize<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\r\n<\/ol><\/pre>\n<p>&nbsp;<\/p>\n<p>\u5f53\u60a8\u5728jshell\u4e2d\u8fd0\u884c\u4e0a\u8ff0\u547d\u4ee4\u65f6\uff0c\u5c06\u4f1a\u5f97\u5230\u5982\u4e0b\u8f93\u51fa\uff1a<\/p>\n<div class=\"secondary-code-label\" title=\"Output\">Output<\/div>\n<pre class=\"post-pre\"><code>prize ==&gt; 32768\r\nwonPrize ==&gt; -32768\r\nYou won: -32768<\/code><\/pre>\n<p>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u60a8\u4f1a\u4e22\u5931\u4fe1\u606f\u5e76\u5f97\u5230\u610f\u60f3\u4e0d\u5230\u7684\u7ed3\u679c\u3002\u5f53\u5c06\u503c32768\u8f6c\u6362\u4e3a<code>short<\/code>\u7c7b\u578b\u65f6\uff0c\u5176\u503c\u53d8\u4e3a-32768\u3002\u8fd9\u662f\u56e0\u4e3a<code>short<\/code>\u7c7b\u578b\u7684\u5b58\u50a8\u5bb9\u91cf\u8303\u56f4\u662f\u4ece-32768\u523032767\u3002\u5f53\u60a8\u8bd5\u56fe\u5b58\u50a8\u4e00\u4e2a\u5927\u4e8e\u6700\u5927\u503c\u7684\u6570\u65f6\uff0c\u4f1a\u53d1\u751f\u6ea2\u51fa\u5e76\u4ece\u6700\u5c0f\u503c\u91cd\u65b0\u5f00\u59cb\u3002\u5728\u8fd9\u4e2a\u6848\u4f8b\u4e2d\uff0c\u5f53\u60a8\u5c1d\u8bd5\u5b58\u50a832768\u65f6\uff0c\u8d85\u8fc7\u4e86\u6700\u5927\u5bb9\u91cf\uff0832767\uff091\u4e2a\u5355\u4f4d\u3002\u56e0\u6b64\uff0c\u4e0b\u4e00\u4e2a\u503c\u4f1a\u4ece\u6700\u5c0f\u53ef\u80fd\u503c\u5f00\u59cb\u5206\u914d\u3002\u5728\u8fd9\u91cc\uff0c\u6700\u5c0f\u503c\u4e3a-32768\u3002<\/p>\n<p>\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u4e0a\u8ff0\u7684\u8f93\u51fa\u770b\u8d77\u6765\u51fa\u4e4e\u610f\u6599\u2014\u2014\u6700\u7ec8\u7684\u5956\u54c1\u6210\u4e3a\u4e86\u4e00\u4e2a\u8d1f\u6570\u3002\u8fd9\u79cd\u95ee\u9898\u5e76\u4e0d\u603b\u662f\u5bb9\u6613\u53d1\u73b0\uff0c\u6240\u4ee5\u60a8\u5e94\u8be5\u8c28\u614e\u4f7f\u7528\u7c7b\u578b\u8f6c\u6362\u3002\u60a8\u53ef\u80fd\u4f1a\u5728\u66f4\u590d\u6742\u7684\u60c5\u5883\u4e2d\u4f7f\u7528\u7c7b\u578b\u8f6c\u6362\uff0c\u8fd9\u5c06\u5728Java\u7cfb\u5217\u7684\u65e5\u540e\u6559\u7a0b\u4e2d\u4ecb\u7ecd\u3002<\/p>\n<h3>\u5173\u7cfb\u8fd0\u7b97\u7b26<\/h3>\n<p>\u5173\u7cfb\u8fd0\u7b97\u7b26\u6bd4\u8f83\u4e24\u4e2a\u64cd\u4f5c\u6570\u5e76\u8fd4\u56de\u4e00\u4e2a\u5e03\u5c14\u503c\u7ed3\u679c\u3002\u5982\u679c\u5173\u7cfb\u6210\u7acb\uff0c\u5219\u7ed3\u679c\u4e3a\u771f\uff08<code>true<\/code>\uff09\u3002\u5982\u679c\u4e0d\u6210\u7acb\uff0c\u5219\u7ed3\u679c\u4e3a\u5047\uff08<code>false<\/code>\uff09\u3002<\/p>\n<p>\u7b2c\u4e00\u7c7b\u5173\u7cfb\u8fd0\u7b97\u7b26\u662f\u7b49\u4e8e\uff08<code>==<\/code>\uff09\u548c\u4e0d\u7b49\u4e8e\uff08<code>!=<\/code>\uff09\u3002\u5b83\u4eec\u7528\u4e8e\u5224\u65ad\u503c\u548c\u5bf9\u8c61\u7684\u76f8\u7b49\u6027\u3002\u5bf9\u4e8e\u539f\u59cb\u503c\u548c\u5b57\u9762\u91cf\uff0c\u5b83\u4eec\u7684\u4f7f\u7528\u7c7b\u4f3c\u4e8e\u6570\u5b66\u3002<\/p>\n<p>\u4e3a\u4e86\u6f14\u793a\u7b49\u4e8e\uff08<code>==<\/code>\uff09\u64cd\u4f5c\u7b26\uff0c\u6211\u4eec\u6bd4\u8f83\u4e24\u4e2a\u6574\u6570\u5e38\u91cf\u3002\u5b9e\u9645\u4e0a\uff0c\u5b83\u4eec\u5c06\u662f\u540c\u4e00\u4e2a\u6570\u5b57\uff1a1\u3002\u60a8\u5c06\u6bd4\u8f83\u5b83\u662f\u5426\u7b49\u4e8e\u81ea\u5df1\uff0c\u4ee5\u4fbf\u60a8\u53ef\u4ee5\u5f97\u5230\u4e00\u4e2a\u771f\uff08<code>true<\/code>\uff09\u7684\u7ed3\u679c\u3002\u5c06\u4ee5\u4e0b\u4ee3\u7801\u7c98\u8d34\u5230jshell\u4e2d\uff1a<\/p>\n<pre class=\"post-pre\"><ol>\r\n \t<li data-prefix=\"jshell&gt;\">System.out.println<span class=\"token punctuation\">(<\/span><mark><span class=\"token number\">1<\/span><span class=\"token operator\">==<\/span><span class=\"token number\">1<\/span><\/mark><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\r\n<\/ol><\/pre>\n<p>&nbsp;<\/p>\n<p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u60a8\u65ad\u8a001\u662f\u5426\u7b49\u4e8e1\u3002\u7531\u4e8e\u8fd9\u4e24\u4e2a\u6570\u5b57\u76f8\u7b49\uff0c\u8be5\u8868\u8fbe\u5f0f\u5f97\u51fa\u7684\u7ed3\u679c\u4e3a<code>true<\/code>\u3002\u56e0\u6b64\uff0c<code>println()<\/code>\u4f1a\u6253\u5370\u51fa<code>true<\/code>\u3002<\/p>\n<div class=\"secondary-code-label\" title=\"Output\">Output<\/div>\n<pre class=\"post-pre\"><code>true<\/code><\/pre>\n<p>\u4ee5\u7ec3\u4e60\u4e3a\u76ee\u7684\uff0c\u5c1d\u8bd5\u66f4\u6539\u5176\u4e2d\u4e00\u4e2a\u503c\uff0c\u4ee5\u83b7\u5f97\u9519\u8bef\u7684\u7ed3\u679c\u3002<\/p>\n<div class=\"post-conf-note\">\n<p class=\"post-conf-desc\"><strong>\u6ce8\u610f\uff1a<\/strong>\u786e\u4fdd\u533a\u5206\u7b49\u4e8e\u64cd\u4f5c\u7b26\u201c<code>==<\/code>\u201d\u548c\u8d4b\u503c\u64cd\u4f5c\u7b26\u201c<code>=<\/code>\u201d\u3002\u5373\u4f7f\u60a8\u77e5\u9053\u5b83\u4eec\u4e0d\u540c\uff0c\u4e5f\u5f88\u5bb9\u6613\u6df7\u6dc6\u5b83\u4eec\u3002\u60a8\u7684\u4ee3\u7801\u5e76\u4e0d\u603b\u662f\u4f1a\u51fa\u73b0\u8bed\u6cd5\u9519\u8bef\uff0c\u8fd9\u53ef\u80fd\u5bfc\u81f4\u96be\u4ee5\u8c03\u8bd5\u7684\u95ee\u9898\u3002<\/p>\n<\/div>\n<p>\u4e0e\u6bd4\u8f83\u539f\u59cb\u503c\u76f8\u6bd4\uff0c\u6bd4\u8f83\u5bf9\u8c61\u7684\u76f8\u7b49\u6027\u66f4\u52a0\u590d\u6742\uff0c\u56e0\u4e3a\u60a8\u8981\u65ad\u5b9a\u4e24\u4e2a\u53d8\u91cf\u662f\u5426\u6307\u5411\u540c\u4e00\u4e2a\u5bf9\u8c61\u3002\u5c1d\u8bd5\u4ee5\u6bd4\u8f83\u4e24\u4e2a\u6574\u6570\uff08<code>Integer<\/code>\uff09\u7684\u4f8b\u5b50\u6765\u8bf4\u660e\u3002<\/p>\n<pre class=\"post-pre\"><ol>\r\n \t<li data-prefix=\"jshell&gt;\">Integer myAnswer <span class=\"token operator\">=<\/span> Integer.valueOf<span class=\"token punctuation\">(<\/span><span class=\"token number\">42<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\r\n \t<li data-prefix=\"jshell&gt;\">Integer yourAnswer <span class=\"token operator\">=<\/span> Integer.valueOf<span class=\"token punctuation\">(<\/span><span class=\"token number\">42<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\r\n \t<li data-prefix=\"jshell&gt;\">System.out.println<span class=\"token punctuation\">(<\/span><mark>myAnswer <span class=\"token operator\">==<\/span> yourAnswer<\/mark><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\r\n<\/ol><\/pre>\n<p>&nbsp;<\/p>\n<p>\u5728\u4ee5\u4e0a\u4ee3\u7801\u4e2d\uff0c\u60a8\u521b\u5efa\u4e86\u4e24\u4e2a\u6574\u6570\u53d8\u91cf\uff0c\u6bcf\u4e2a\u53d8\u91cf\u7684\u503c\u90fd\u4e3a42\u3002\u5728\u6700\u540e\u4e00\u884c\uff0c\u60a8\u6bd4\u8f83\u5b83\u4eec\u662f\u5426\u76f8\u7b49\uff0c\u5e76\u4e14\u5982\u679c\u5b83\u4eec\u76f8\u7b49\u5219\u6253\u5370<code>true<\/code>\u3002\u6839\u636e\u6211\u4eec\u4e4b\u524d\u7684Java\u6570\u636e\u7c7b\u578b\u6559\u7a0b\uff0c\u60a8\u53ef\u80fd\u77e5\u9053<code>Integer.valueOf()<\/code>\u9996\u5148\u5728\u7f13\u5b58\u4e2d\u68c0\u67e5\u662f\u5426\u6709\u5177\u6709\u76f8\u540c\u503c\u7684\u5bf9\u8c61\uff0c\u5e76\u4e14\u5982\u679c\u5df2\u7ecf\u5b58\u5728\u4e00\u4e2a\u5177\u6709\u8be5\u503c\u7684\u5bf9\u8c61\uff0c\u5219\u8fd4\u56de\u540c\u4e00\u4e2a\u5bf9\u8c61\u3002\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48<code>myAnswer<\/code>\u548c<code>yourAnswer<\/code>\u90fd\u5f97\u5230\u4e86\u76f8\u540c\u7684\u5bf9\u8c61\u3002<\/p>\n<p>\u5f53\u60a8\u628a\u4ee5\u4e0a\u7684\u4ee3\u7801\u7c98\u8d34\u5230jshell\u4e2d\u65f6\uff0c\u60a8\u5c06\u4f1a\u5f97\u5230\u4ee5\u4e0b\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<div class=\"secondary-code-label\" title=\"Output\">Output<\/div>\n<p>\u8fd9\u662f\u6587\u7ae0\u300a\u5982\u4f55\u5728Java\u4e2d\u4f7f\u7528\u8fd0\u7b97\u7b26\u300b\u7684\u7b2c5\u90e8\u5206\uff08\u51718\u90e8\u5206\uff09\u3002<\/p>\n<pre class=\"post-pre\"><code>myAnswer ==&gt; 42\r\nyourAnswer ==&gt; 42\r\ntrue<\/code><\/pre>\n<p>\u8fd9\u79cd\u5bf9\u8c61\u6bd4\u8f83\u770b\u8d77\u6765\u5f88\u7b80\u5355\uff0c\u4f46\u6709\u65f6\u5019\u4f1a\u6709\u6311\u6218\u3002\u5176\u4e2d\u6700\u4ee4\u4eba\u56f0\u60d1\u7684\u4f8b\u5b50\u662f\u5b57\u7b26\u4e32\u6bd4\u8f83\u3002\u5c1d\u8bd5\u6bd4\u8f83\u4e24\u4e2a\u5177\u6709\u76f8\u540c\u503c\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">String answer1 <span class=\"token operator\">=<\/span> new String<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#8220;yes&#8221;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">String answer2 <span class=\"token operator\">=<\/span> new String<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#8220;yes&#8221;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">System.out.println<span class=\"token punctuation\">(<\/span><mark>answer1 <span class=\"token operator\">==<\/span> answer2<\/mark><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u9996\u5148\uff0c\u4f60\u58f0\u660e\u4e86\u4e24\u4e2a\u65b0\u7684String\u53d8\u91cf\uff08answer1\u548canswer2\uff09\uff0c\u5b83\u4eec\u7684\u503c\u90fd\u4e3a&#8221;yes&#8221;\u3002\u7136\u800c\uff0c\u4f60\u4f7f\u7528\u4e86<code>new<\/code>\u5173\u952e\u5b57\u6765\u521b\u5efa\u65b0\u7684String\u5bf9\u8c61\u3002\u56e0\u6b64\uff0c\u8fd9\u4e24\u4e2a\u53d8\u91cf\u5e76\u4e0d\u6307\u5411\u540c\u4e00\u4e2a\u5bf9\u8c61\u2014\u2014\u5b83\u4eec\u5b9e\u9645\u4e0a\u6307\u5411\u4e24\u4e2a\u4e0d\u540c\u7684\u5bf9\u8c61\uff08\u4f46\u503c\u76f8\u540c\uff09\u3002<\/p>\n<p>\u5f53\u4f60\u5c06\u4ee5\u4e0a\u4ee3\u7801\u7c98\u8d34\u5230jshell\u4e2d\u65f6\uff0c\u4f60\u5c06\u5f97\u5230\u4ee5\u4e0b\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<pre class=\"post-pre\"><div class=\"secondary-code-label\" title=\"Output\">Output<\/div><code>answer1 ==&gt; \"yes\"\r\nanswer2 ==&gt; \"yes\"\r\nfalse<\/code><\/pre>\n<p>\u5373\u4f7fanswer1\u548canswer2\u7684\u503c\u76f8\u540c\uff08\u90fd\u662f\u201cyes\u201d\uff09\uff0c\u5b83\u4eec\u7684\u76f8\u7b49\u6027\u8bc4\u4f30\u7ed3\u679c\u5374\u662f<code>false<\/code>\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u4eec\u662f\u4e0d\u76f8\u7b49\u7684\u3002\u5982\u679c\u60a8\u6253\u7b97\u6bd4\u8f83\u503c\uff0c\u4f8b\u5982\u5224\u65ad\u4e24\u4e2a\u7b54\u6848\u662f\u5426\u90fd\u662f\u80af\u5b9a\u7684\uff0c\u800c\u4e0d\u5173\u5fc3\u5e95\u5c42\u5bf9\u8c61\uff0c\u90a3\u4e48\u8fd9\u53ef\u80fd\u4ee4\u4eba\u56f0\u60d1\u3002\u4e3a\u6b64\uff0c\u8bb8\u591a\u7c7b\uff08\u5305\u62ec\u5b57\u7b26\u4e32\uff09\u90fd\u6709\u4e13\u95e8\u7684\u65b9\u6cd5\u7528\u4e8e\u65ad\u8a00\u76f8\u7b49\u6027\u3002<\/p>\n<p>\u5728\u5b57\u7b26\u4e32\u7684\u60c5\u51b5\u4e0b\uff0c\u6b64\u65b9\u6cd5\u662f<code>equals()<\/code>\u3002\u5c1d\u8bd5\u66f4\u6539\u4ee3\u7801\u4ee5\u4f7f\u7528<code>equals()<\/code>\uff08\u800c\u4e0d\u662f<code>==<\/code>\uff09\uff0c\u50cf\u8fd9\u6837\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">String answer1 <span class=\"token operator\">=<\/span> new String<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#8220;yes&#8221;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">String answer2 <span class=\"token operator\">=<\/span> new String<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#8220;yes&#8221;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">System.out.println<span class=\"token punctuation\">(<\/span>answer1.<mark>equals<span class=\"token punctuation\">(<\/span>answer2<span class=\"token punctuation\">)<\/span><\/mark><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p><code>equals()<\/code>\u65b9\u6cd5\u7528\u4e8e\u9a8c\u8bc1\u6bd4\u8f83\u5bf9\u8c61\u4e2d\u5305\u542b\u7684\u5b57\u7b26\u4e32\u662f\u5426\u76f8\u7b49\u3002<\/p>\n<p>\u5f53\u4f60\u5c06\u8fd9\u6bb5\u4ee3\u7801\u7c98\u8d34\u5230JShell\u4e2d\u65f6\uff0c\u4f60\u5c06\u5f97\u5230\u4ee5\u4e0b\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<pre class=\"post-pre\"><div class=\"secondary-code-label\" title=\"Output\">Output<\/div><code>answer1 ==&gt; \"yes\"\r\nanswer2 ==&gt; \"yes\"\r\ntrue<\/code><\/pre>\n<p>\u4ee5\u4e0a\u8f93\u51fa\u4e0e\u4e0a\u4e00\u4e2a\u8f93\u51fa\u76f8\u4f3c\uff0c\u4f46\u5b83\u4ee5<code>true<\/code>\u7ed3\u5c3e\uff0c\u786e\u8ba4\u4e86\u4e24\u4e2a\u5bf9\u8c61\u7684\u503c\u662f\u76f8\u7b49\u7684\u3002\u8fd9\u4e2a\u4f8b\u5b50\u8bc1\u660e\u4e86\u5728\u6bd4\u8f83\u5f15\u7528\u7c7b\u578b\u65f6\uff0c\u4f60\u5fc5\u987b\u5c0f\u5fc3\uff0c\u5e76\u5728\u53ef\u7528\u65f6\u4f7f\u7528\u76f8\u5e94\u7684\u65b9\u6cd5\u3002<\/p>\n<p>\u4e00\u4e2a\u9009\u62e9\u7684\u7b49\u4e8e\u64cd\u4f5c\u7b26\uff0c\u4e0d\u662f\u7b49\u4e8e<code>!=<\/code>\uff0c\u7528\u6cd5\u7c7b\u4f3c\uff0c\u4f46\u5b83\u65ad\u8a00\u4e24\u4e2a\u53d8\u91cf\u6216\u503c\u662f\u5426\u4e0d\u76f8\u540c\uff08\u6216\u4e0d\u7b49\uff09\u3002\u4f5c\u4e3a\u7ec3\u4e60\uff0c\u5728\u4e4b\u524d\u7684\u4e00\u4e9b\u793a\u4f8b\u4e2d\u5c1d\u8bd5\u4f7f\u7528<code>!=<\/code>\u66ff\u6362<code>==<\/code>\u3002<\/p>\n<p>\u7c7b\u4f3c\u4e8e<code>==<\/code>\u548c<code>!=<\/code>\uff0c\u4e0b\u9762\u7684\u56db\u4e2a\u5173\u7cfb\u8fd0\u7b97\u7b26\u4e5f\u6e90\u81ea\u6570\u5b66\uff1a\u5c0f\u4e8e<code>&lt;<\/code>\uff0c\u5c0f\u4e8e\u7b49\u4e8e<code>&lt;=<\/code>\uff0c\u5927\u4e8e<code>&gt;<\/code>\uff0c\u5927\u4e8e\u7b49\u4e8e<code>&gt;=<\/code>\u3002<\/p>\n<p>\u8fd9\u662f\u4e00\u4e2a\u4f7f\u7528\u5927\u4e8e\u64cd\u4f5c\u7b26\u7684\u793a\u4f8b\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">System.out.println<span class=\"token punctuation\">(<\/span><span class=\"token number\">4<\/span> <mark><span class=\"token operator\">><\/span><\/mark> <span class=\"token number\">5<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u5f53\u4f60\u5728jshell\u4e2d\u8fd0\u884c\u8fd9\u6bb5\u4ee3\u7801\u65f6\uff0c\u4f60\u5c06\u4f1a\u5f97\u5230\u4ee5\u4e0b\u8f93\u51fa\uff1a<\/p>\n<pre class=\"post-pre\"><div class=\"secondary-code-label\" title=\"Output\">Output<\/div><code>false<\/code><\/pre>\n<p>\u4ee5\u4e0a\u7684\u4ee3\u7801\u9996\u5148\u6bd4\u8f83\u4e864\u662f\u5426\u5927\u4e8e5\u3002\u7531\u4e8e\u4e0d\u662f\uff0c\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\u4e3a<code>false<\/code>\u3002\u7136\u540e\uff0c<code>println()<\/code>\u65b9\u6cd5\u6253\u5370\u4e86\u6bd4\u8f83\u7684\u7ed3\u679c\uff08<code>false<\/code>\uff09\u3002<\/p>\n<p>\u5728 Java \u4e2d\uff0c\u6700\u540e\u4e00\u4e2a\u5173\u7cfb\u8fd0\u7b97\u7b26\u662f<code>instanceof<\/code>\uff0c\u5b83\u7528\u4e8e\u8bc4\u4f30\u4e00\u4e2a\u53d8\u91cf\u662f\u5426\u662f\u7ed9\u5b9a\u7c7b\uff08\u6216\u5b50\u7c7b\uff09\u7684\u5b9e\u4f8b\u6216\u63a5\u53e3\u7684\u5b9e\u73b0\u3002\u5982\u6211\u4eec\u5728\u300a\u4e86\u89e3 Java \u4e2d\u7684\u6570\u636e\u7c7b\u578b\u300b\u6559\u7a0b\u4e2d\u6240\u89e3\u91ca\u7684\u90a3\u6837\uff0c\u63a5\u53e3\u662f\u4e00\u4e2a\u5177\u6709\u4e00\u7ec4\u8981\u6c42\u7684\u62bd\u8c61\u5b9e\u4f53\u3002<\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u793a\u4f8b\u6765\u63a2\u7d22<code>instanceof<\/code>\u7684\u5de5\u4f5c\u539f\u7406\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">String greeting <span class=\"token operator\">=<\/span> <span class=\"token string\">&#8220;hello&#8221;<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">System.out.println<span class=\"token punctuation\">(<\/span>greeting <mark>instanceof<\/mark> String<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u9996\u5148\uff0c\u4f60\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>greeting<\/code>\u7684\u5b57\u7b26\u4e32\u53d8\u91cf\u3002\u7136\u540e\uff0c\u5728\u62ec\u53f7\u4e2d\u8bc4\u4f30<code>greeting<\/code>\u662f\u5426\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\u5b9e\u4f8b\u3002<\/p>\n<p>\u5f53\u4f60\u5728jshell\u4e2d\u7c98\u8d34\u4ee3\u7801\u65f6\uff0c\u4f60\u5c06\u83b7\u5f97\u4ee5\u4e0b\u8f93\u51fa\uff1a<\/p>\n<pre class=\"post-pre\"><div class=\"secondary-code-label\" title=\"Output\">Output<\/div><code>greeting ==&gt; \"hello\"\r\ntrue<\/code><\/pre>\n<p>\u7531\u4e8e<code>greeting<\/code>\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\u5b9e\u4f8b\uff0c\u6240\u4ee5\u8868\u8fbe\u5f0f\u7684\u503c\u4e3a<code>true<\/code>\uff0c\u901a\u8fc7<code>println()<\/code>\u51fd\u6570\u5728\u5c4f\u5e55\u4e0a\u6253\u5370\u3002<\/p>\n<h3>\u903b\u8f91\u8fd0\u7b97\u7b26<\/h3>\n<p>\u8fd9\u662f\u6587\u7ae0\u300a\u5982\u4f55\u5728Java\u4e2d\u4f7f\u7528\u8fd0\u7b97\u7b26\u300b\u7684\u7b2c6\u90e8\u5206\uff08\u51718\u90e8\u5206\uff09\u3002<\/p>\n<p>\u5185\u5bb9\u7247\u6bb5: \u903b\u8f91\u8fd0\u7b97\u7b26\u5305\u62ec\u903b\u8f91\u4e0e\uff08<code>&amp;<\/code>\uff09\u3001\u903b\u8f91\u6216\uff08<code>|<\/code>\uff09\u548c\u5f02\u6216\uff08<code>^<\/code>\uff09\u3002\u5b83\u4eec\u90fd\u6309\u7167\u4ee5\u4e0b\u65b9\u5f0f\u5bf9\u4e24\u4e2a\u503c\u8fdb\u884c\u8bc4\u4f30\uff1a<\/p>\n<ul class=\"post-ul\">\n<li>\u903b\u8f91\u4e0e\uff1a\u5f53\u4e24\u4e2a\u503c\u90fd\u4e3a\u771f\u65f6\uff0c\u7ed3\u679c\u4e3a\u771f\u3002<\/li>\n<li>\u903b\u8f91\u6216\uff1a\u5f53\u81f3\u5c11\u4e00\u4e2a\u503c\u4e3a\u771f\u65f6\uff0c\u7ed3\u679c\u4e3a\u771f\u3002<\/li>\n<li>\u5f02\u6216\uff1a\u5f53\u4e00\u4e2a\u503c\u4e3a\u771f\u800c\u53e6\u4e00\u4e2a\u503c\u4e3a\u5047\u65f6\uff0c\u7ed3\u679c\u4e3a\u771f\u3002<\/li>\n<\/ul>\n<p>\u5f53\u903b\u8f91\u8fd0\u7b97\u7b26\u4e0d\u6ee1\u8db3\u4e0a\u8ff0\u6761\u4ef6\u65f6\uff0c\u5b83\u4eec\u7684\u7ed3\u679c\u4e3a\u5047\u3002<\/p>\n<p>\u8981\u4f7f\u7528\u903b\u8f91\u4e0e\uff08<code>&amp;<\/code>\uff09\u8fd0\u7b97\u7b26\uff0c\u8bf7\u5c06\u4ee5\u4e0b\u793a\u4f8b\u7c98\u8d34\u5230jshell\u4e2d\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">boolean isJavaFun <span class=\"token operator\">=<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">boolean isJavaPowerful <span class=\"token operator\">=<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">System.out.println<span class=\"token punctuation\">(<\/span>isJavaFun <mark><span class=\"token operator\">&amp;<\/span><\/mark> isJavaPowerful<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u524d\u4e24\u884c\u5b9a\u4e49\u4e86\u4e24\u4e2a\u5e03\u5c14\u53d8\u91cf<code>isJavaFun<\/code>\u548c<code>isJavaPowerful<\/code>\uff0c\u90fd\u8d4b\u503c\u4e3a<code>true<\/code>\u3002\u5728\u7b2c\u4e09\u884c\uff0c\u4f60\u5728\u62ec\u53f7\u4e2d\u5bf9<code>isJavaFun<\/code>\u548c<code>isJavaPowerful<\/code>\u6267\u884c\u4e86\u903b\u8f91\u4e0e\u64cd\u4f5c\uff0c\u5e76\u4e14\u7ed3\u679c\u7531<code>println()<\/code>\u51fd\u6570\u8f93\u51fa\u3002<\/p>\n<p>\u5f53\u4f60\u5c06\u8fd9\u6bb5\u4ee3\u7801\u7c98\u8d34\u5230jshell\u4e2d\u65f6\uff0c\u4f60\u5c06\u4f1a\u5f97\u5230\u4ee5\u4e0b\u8f93\u51fa\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">\u8f93\u51fa<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>isJavaFun ==&gt; true isJavaPowerful ==&gt; true true<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<\/div>\n<p>\u4e24\u4e2a\u53d8\u91cf\u90fd\u88ab\u8bbe\u7f6e\u4e3a\u771f\uff0c\u5e76\u901a\u8fc7\u903b\u8f91\u4e0e\u8fd0\u7b97\u7684\u7ed3\u679c\u6253\u5370\u51fa\u6700\u540e\u7684\u771f\u503c\u3002<\/p>\n<p>\u8981\u589e\u52a0\u4f60\u7684\u6280\u80fd\uff0c\u5c1d\u8bd5\u4f7f\u7528\u524d\u9762\u7684\u4ee3\u7801\u793a\u4f8b\u5e76\u8fdb\u884c\u4e00\u4e9b\u53d8\u5316\u3002\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u5728\u53d8\u91cf\u4e4b\u95f4\u5207\u6362<code>true<\/code>\u548c<code>false<\/code>\u7684\u503c\u3002\u4f60\u4e5f\u53ef\u4ee5\u5c1d\u8bd5\u5c06\u903b\u8f91\u8fd0\u7b97\u7b26\u6539\u4e3a\u903b\u8f91\u6216\uff08<code>|<\/code>\uff09\u548c\u5f02\u6216\uff08<code>^<\/code>\uff09\u3002<\/p>\n<p>\u903b\u8f91\u8fd0\u7b97\u7b26\u7684\u6269\u5c55\u7248\u672c\u662f\u6240\u8c13\u7684\u77ed\u8def\u903b\u8f91\u8fd0\u7b97\u7b26\uff1a\u77ed\u8def\u4e0e\uff08<code>&amp;&amp;<\/code>\uff09\u548c\u77ed\u8def\u6216\uff08<code>||<\/code>\uff09\u3002\u5b83\u4eec\u4e0e\u5e38\u89c4\u7684\u903b\u8f91\u4e0e\u548c\u903b\u8f91\u6216\u8fd0\u7b97\u7b26\u7c7b\u4f3c\uff0c\u4f46\u6709\u4e00\u4e2a\u91cd\u8981\u7684\u533a\u522b\uff1a\u5982\u679c\u7b2c\u4e00\u4e2a\u64cd\u4f5c\u6570\u7684\u8bc4\u4f30\u7ed3\u679c\u8db3\u4ee5\u786e\u5b9a\u6574\u4e2a\u8868\u8fbe\u5f0f\u7684\u503c\uff0c\u90a3\u4e48\u7b2c\u4e8c\u4e2a\u64cd\u4f5c\u6570\u5c06\u4e0d\u4f1a\u88ab\u8bc4\u4f30\u3002\u56e0\u6b64\uff0c\u4e3a\u4e86\u4f7f\u77ed\u8def\u4e0e\u4e3a\u771f\uff0c\u5b83\u4e24\u8fb9\u7684\u6761\u4ef6\u90fd\u5fc5\u987b\u4e3a\u771f\u3002\u7136\u800c\uff0c\u5982\u679c\u5de6\u8fb9\u4e3a\u5047\uff0c\u5219\u4e0d\u4f1a\u8bc4\u4f30\u53f3\u8fb9\u3002\u7c7b\u4f3c\u5730\uff0c\u5bf9\u4e8e\u77ed\u8def\u6216\uff0c\u5982\u679c\u5de6\u8fb9\u4e3a\u771f\uff0c\u5219\u4e0d\u4f1a\u8bc4\u4f30\u53f3\u8fb9\u3002<\/p>\n<p>\u8fd9\u91cc\u4e3e\u4e00\u4e2a\u4f7f\u7528\u77ed\u8def\u903b\u8f91\u6216\u7684\u4f8b\u5b50\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">boolean isJavaFun <span class=\"token operator\">=<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">Boolean isNullFun <span class=\"token operator\">=<\/span> null<span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">System.out.println<span class=\"token punctuation\">(<\/span>isJavaFun <mark><span class=\"token operator\">||<\/span><\/mark> isNullFun<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u9996\u5148\uff0c\u4f60\u5c06\u53d8\u91cf<code>isJavaFun<\/code>\u8d4b\u503c\u4e3a<code>true<\/code>\u3002\u4e3a\u4e86\u4e0e\u4e4b\u524d\u7684\u793a\u4f8b\u4fdd\u6301\u4e00\u81f4\u6027\uff0c\u8fd9\u4e2a\u53d8\u91cf\u662f\u57fa\u672c\u7c7b\u578b<code>boolean<\/code>\u3002\u7136\u800c\uff0c\u5bf9\u4e8e\u4e0b\u4e00\u4e2a\u53d8\u91cf<code>isNullFun<\/code>\uff0c\u4f60\u4f7f\u7528<code>Boolean<\/code>\u5f15\u7528\u7c7b\u578b\uff0c\u4ee5\u4fbf\u53ef\u4ee5\u5c06\u5176\u8d4b\u503c\u4e3a<code>null<\/code>\u3002\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u4f60\u6709\u4e00\u4e2a\u6307\u5411<code>null<\/code>\u7684\u53d8\u91cf\u5f88\u91cd\u8981\uff0c\u4f46\u662f\u6b63\u5982\u4f60\u53ef\u80fd\u8fd8\u8bb0\u5f97\u7684\uff0c\u5728\u7406\u89e3Java\u6570\u636e\u7c7b\u578b\u7684\u6559\u7a0b\u4e2d\uff0c\u57fa\u672c\u7c7b\u578b\u4e0d\u80fd\u4e3a<code>null<\/code>\uff0c\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u4f60\u4f7f\u7528\u4e86\u5f15\u7528\u7c7b\u578b\u7684\u539f\u56e0\u3002<\/p>\n<p>\u5f53\u77ed\u8def\u6216\u8fd0\u7b97\u7b26\u53d1\u751f\u5728\u62ec\u53f7\u4e2d\u65f6\uff0c\u7531\u4e8e\u5de6\u4fa7\u4e3a\u771f\uff0c<code>isNullFun<\/code>\u88ab\u5ffd\u7565\uff0c\u8fd9\u5c31\u8db3\u4ee5\u4f7f\u6574\u4e2a\u8868\u8fbe\u5f0f\u4e3a\u771f\u3002\u56e0\u6b64\uff0c\u5f53\u60a8\u5728jshell\u4e2d\u8fd0\u884c\u4ee3\u7801\u65f6\uff0c\u5c06\u6253\u5370\u4ee5\u4e0b\u8f93\u51fa\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">\u8f93\u51fa<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>isJavaFun ==&gt; true isNullFun ==&gt; null true<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<\/div>\n<p>\u7b2c\u4e00\u884c\u548c\u7b2c\u4e8c\u884c\u786e\u8ba4\u53d8\u91cf\u88ab\u8d4b\u503c\u4e3a\u771f\u548c\u7a7a\u503c\u3002\u7b2c\u4e09\u884c\u6253\u5370\u771f\uff0c\u56e0\u4e3a\u77ed\u8def\u6216\u64cd\u4f5c\u8fd4\u56de\u4e86\u771f\u3002<\/p>\n<p>\u4ee5\u4e0a\u7684\u4f8b\u5b50\u662f\u9009\u62e9\u7279\u5b9a\u7684\u7a7a\u503c\u6765\u5c55\u793a\u77ed\u8def\u8fd0\u7b97\u7b26\u7684\u5de5\u4f5c\u539f\u7406\uff0c\u5e76\u4e14<code>isNullFun<\/code>\u4e0d\u4f1a\u88ab\u6267\u884c\u3002\u8981\u770b\u5230<code>isNullFun<\/code>\u88ab\u6267\u884c\uff0c\u8bf7\u5c1d\u8bd5\u5c06\u77ed\u8def\u6216\u8fd0\u7b97\u7b26\u66f4\u6539\u4e3a\u666e\u901a\u7684\u6216\u8fd0\u7b97\u7b26\uff0c\u50cf\u8fd9\u6837\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">boolean isJavaFun <span class=\"token operator\">=<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">Boolean isNullFun <span class=\"token operator\">=<\/span> null<span class=\"token punctuation\">;<\/span><\/li>\n<li data-prefix=\"jshell&gt;\">System.out.println<span class=\"token punctuation\">(<\/span>isJavaFun <mark><span class=\"token operator\">|<\/span><\/mark> isNullFun<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u5e38\u89c4\u7684\u903b\u8f91\u6216\u8fd0\u7b97\u7b26\u4f1a\u540c\u65f6\u5bf9\u8868\u8fbe\u5f0f\u7684\u4e24\u4fa7\u8fdb\u884c\u6c42\u503c\u3002<\/p>\n<p>\u5f53\u60a8\u5728jshell\u4e2d\u8fd0\u884c\u6b64\u4ee3\u7801\u65f6\uff0c\u60a8\u5c06\u83b7\u5f97\u4ee5\u4e0b\u8f93\u51fa\uff1a<\/p>\n<pre class=\"post-pre\"><code>isJavaFun ==&gt; true\r\nisNullFun ==&gt; null\r\n|  Exception java.lang.NullPointerException\r\n|        at (#3:1)\r\n<\/code><\/pre>\n<p>\u5f53\u903b\u8f91\u6216\u5c1d\u8bd5\u8bc4\u4f30<code>null<\/code>\u65f6\uff0c\u4f60\u4f1a\u5f97\u5230<code>java.lang.NullPointerException<\/code>\u3002\u56e0\u6b64\uff0c\u77ed\u8def\u8fd0\u7b97\u7b26\u66f4\u53d7\u9752\u7750\uff0c\u51e0\u4e4e\u603b\u662f\u4f7f\u7528\u800c\u4e0d\u662f\u5e38\u89c4\u903b\u8f91\u8fd0\u7b97\u7b26\u3002<\/p>\n<p>\u4f5c\u4e3a\u7ec3\u4e60\uff0c\u5c1d\u8bd5\u4f7f\u7528\u77ed\u8def\u8fd0\u7b97\u7b26<code>&amp;&amp;<\/code>\u548c<code>||<\/code>\uff0c\u5b83\u4eec\u662f\u6700\u53d7\u6b22\u8fce\u548c\u6700\u6709\u7528\u7684\u8fd0\u7b97\u7b26\u3002<\/p>\n<p>\u5728\u672c\u8282\u4e2d\uff0c\u4f60\u5728\u4e00\u7cfb\u5217\u7684\u4f8b\u5b50\u4e2d\u4f7f\u7528\u4e86\u4e8c\u8fdb\u5236\u8fd0\u7b97\u7b26\uff0c\u4ece\u57fa\u672c\u7b97\u672f\u5230\u6d89\u53ca\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\u548c\u6bd4\u8f83\u5bf9\u8c61\u76f8\u7b49\u6027\u7684\u66f4\u5177\u6311\u6218\u6027\u7684\u64cd\u4f5c\u3002\u5728\u4e0b\u4e00\u8282\u4e2d\uff0c\u4f60\u5c06\u4f7f\u7528\u4e09\u4e2a\u64cd\u4f5c\u6570\u6765\u8fdb\u884c\u64cd\u4f5c\u3002<\/p>\n<h2>\u4e09\u5143\u8fd0\u7b97\u7b26<\/h2>\n<h2>Java\u8fd0\u7b97\u7b26\u7cfb\u5217\u6559\u7a0b\uff1a\u4e09\u5143\u8fd0\u7b97\u7b26\u8be6\u89e3<\/h2>\n<p>\u8fd9\u662f\u6587\u7ae0\u300a\u5982\u4f55\u5728Java\u4e2d\u4f7f\u7528\u8fd0\u7b97\u7b26\u300b\u7684\u7b2c7\u90e8\u5206\uff08\u51718\u90e8\u5206\uff09\u3002<\/p>\n<p>\u5728\u4e4b\u524d\u7684\u7ae0\u8282\u4e2d\uff0c\u60a8\u5df2\u7ecf\u7ec3\u4e60\u4e86\u4f7f\u7528\u4e00\u4e2a\u6216\u4e24\u4e2a\u64cd\u4f5c\u6570\u7684\u8fd0\u7b97\u7b26\u3002\u5728\u672c\u8282\u4e2d\uff0c\u60a8\u5c06\u6df1\u5165\u4e86\u89e3\u4e09\u5143\u8fd0\u7b97\u7b26\uff0c\u5b83\u662fJava\u4e2d\u552f\u4e00\u4e00\u4e2a\u9700\u8981\u4e09\u4e2a\u64cd\u4f5c\u6570\u7684\u8fd0\u7b97\u7b26\u3002\u5176\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre><code>\u7b2c\u4e00\u4e2a\u64cd\u4f5c\u6570 ? \u7b2c\u4e8c\u4e2a\u64cd\u4f5c\u6570 : \u7b2c\u4e09\u4e2a\u64cd\u4f5c\u6570;<\/code><\/pre>\n<p>\u5176\u4e2d\uff0c\u7b2c\u4e00\u4e2a\u64cd\u4f5c\u6570\u5fc5\u987b\u662f\u4e00\u4e2a\u5e03\u5c14\u8868\u8fbe\u5f0f\u3002\u5982\u679c\u8be5\u5e03\u5c14\u8868\u8fbe\u5f0f\u8bc4\u4f30\u4e3a<code>true<\/code>\uff0c\u5219\u6574\u4e2a\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\u5c06\u662f\u7b2c\u4e8c\u4e2a\u64cd\u4f5c\u6570\u7684\u503c\uff1b\u53cd\u4e4b\uff0c\u5982\u679c\u8bc4\u4f30\u4e3a<code>false<\/code>\uff0c\u5219\u8fd4\u56de\u7b2c\u4e09\u4e2a\u64cd\u4f5c\u6570\u7684\u503c\u3002<\/p>\n<p>\u4e09\u5143\u8fd0\u7b97\u7b26\u56e0\u5176\u80fd\u591f\u6709\u6548\u907f\u514d\u7f16\u5199\u5197\u957f\u7684<code>if-else<\/code>\u6761\u4ef6\u8bed\u53e5\uff0c\u5e76\u51cf\u5c11\u5bf9\u4e34\u65f6\u53d8\u91cf\u7684\u4f9d\u8d56\u800c\u5e7f\u53d7\u6b22\u8fce\u548c\u9891\u7e41\u4f7f\u7528\u3002<\/p>\n<h3>\u4e09\u5143\u8fd0\u7b97\u7b26\u793a\u4f8b<\/h3>\n<p>\u4ee5\u4e0b\u793a\u4f8b\u5c55\u793a\u4e86\u5982\u4f55\u5728Java\u4e2d\u4f7f\u7528\u4e09\u5143\u8fd0\u7b97\u7b26\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">boolean isJavaFun = true;<\/li>\n<li data-prefix=\"jshell&gt;\">String shouldILearnJava = <mark>isJavaFun ? &#8220;yes&#8221; : &#8220;no&#8221;;<\/mark><\/li>\n<li data-prefix=\"jshell&gt;\">System.out.println(&#8220;Should I learn Java: &#8221; + shouldILearnJava);<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u5728\u6b64\u793a\u4f8b\u4e2d\uff0c<code>isJavaFun<\/code>\u7684\u503c\u88ab\u521d\u59cb\u5316\u4e3a<code>true<\/code>\uff0c\u5e76\u4e14\u53d8\u91cf<code>shouldILearnJava<\/code>\u901a\u8fc7\u4e09\u5143\u8fd0\u7b97\u7b26\u8fdb\u884c\u8d4b\u503c\u3002\u7531\u4e8e\u7b2c\u4e00\u4e2a\u64cd\u4f5c\u6570<code>isJavaFun<\/code>\u4e3a<code>true<\/code>\uff0c\u56e0\u6b64\u8868\u8fbe\u5f0f\u8fd4\u56de\u7b2c\u4e8c\u4e2a\u64cd\u4f5c\u6570\uff0c\u5373\u5b57\u7b26\u4e32<code>\"yes\"<\/code>\u3002\u4e3a\u4e86\u9a8c\u8bc1\u8fd9\u4e00\u70b9\uff0c\u7b2c\u4e09\u884c\u4ee3\u7801\u6253\u5370\u4e86<code>shouldILearnJava<\/code>\u53d8\u91cf\u7684\u503c\uff0c\u9884\u671f\u8f93\u51fa\u4e3a<code>yes<\/code>\u3002<\/p>\n<p>\u5f53\u60a8\u8fd0\u884c\u4ee5\u4e0a\u4ee3\u7801\u65f6\uff0c\u5c06\u5f97\u5230\u4ee5\u4e0b\u8f93\u51fa\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">\u8f93\u51fa<\/div>\n<pre class=\"post-pre\"><code>Should I learn Java: yes<\/code><\/pre>\n<p>\u4e3a\u4e86\u8fdb\u4e00\u6b65\u7ec3\u4e60\uff0c\u8bf7\u5c1d\u8bd5\u5728<code>isJavaFun<\/code>\u524d\u9762\u4f7f\u7528\u903b\u8f91\u975e\uff08<code>!<\/code>\uff09\u8fd0\u7b97\u7b26\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">boolean isJavaFun = true;<\/li>\n<li data-prefix=\"jshell&gt;\">String shouldILearnJava = <mark>!isJavaFun ? &#8220;yes&#8221; : &#8220;no&#8221;;<\/mark><\/li>\n<li data-prefix=\"jshell&gt;\">System.out.println(&#8220;Should I learn java: &#8221; + shouldILearnJava);<\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u901a\u8fc7\u5728<code>isJavaFun<\/code>\u524d\u6dfb\u52a0\u903b\u8f91\u975e\u8fd0\u7b97\u7b26\uff0c\u5176\u5e03\u5c14\u503c\u4ece<code>true<\/code>\u53cd\u8f6c\u4e3a<code>false<\/code>\u3002\u56e0\u6b64\uff0c\u4e09\u5143\u8868\u8fbe\u5f0f\u5c06\u8fd4\u56de\u7b2c\u4e09\u4e2a\u64cd\u4f5c\u6570\uff0c\u5373\u5b57\u7b26\u4e32<code>\"no\"<\/code>\u3002<\/p>\n<p>\u5c3d\u7ba1\u4e09\u5143\u8868\u8fbe\u5f0f\uff0c\u7279\u522b\u662f\u5f53\u4e0e\u903b\u8f91\u975e\u7b49\u9644\u52a0\u8fd0\u7b97\u7b26\u7ed3\u5408\u4f7f\u7528\u65f6\uff0c\u53ef\u80fd\u4f1a\u8ba9\u4eba\u611f\u5230\u6709\u4e9b\u56f0\u60d1\uff0c\u4f46\u5b83\u4eec\u5728\u51cf\u5c11\u4ee3\u7801\u5197\u4f59\u65b9\u9762\u8868\u73b0\u51fa\u8272\uff0c\u8fd9\u4e5f\u662f\u5b83\u4eec\u5907\u53d7\u6b22\u8fce\u7684\u539f\u56e0\u3002<\/p>\n<h2>\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7<\/h2>\n<p>\u8fd9\u662f\u6587\u7ae0\u300a\u5982\u4f55\u5728Java\u4e2d\u4f7f\u7528\u8fd0\u7b97\u7b26\u300b\u7684\u7b2c8\u90e8\u5206\uff08\u51718\u90e8\u5206\uff09\u3002<\/p>\n<p>\u4e00\u65e6\u4f60\u4e86\u89e3\u4e86\u91cd\u8981\u7684\u8fd0\u7b97\u7b26\uff0c\u4f60\u5c31\u80fd\u591f\u4f7f\u7528\u751a\u81f3\u7ec4\u5408\u5b83\u4eec\u3002\u4f46\u5728\u4f60\u5f00\u59cb\u7ec4\u5408\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u4e86\u89e3\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\u7684\u89c4\u5219\u3002<\/p>\n<p>\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\u51b3\u5b9a\u4e86\u8fd0\u7b97\u7b26\u7684\u8bc4\u4f30\u987a\u5e8f\u3002\u7531\u4e8e\u4f60\u53ef\u80fd\u4f1a\u4f7f\u7528\u591a\u4e2a\u8fd0\u7b97\u7b26\uff0c\u56e0\u6b64\u4e86\u89e3\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\u975e\u5e38\u91cd\u8981\u3002\u867d\u7136\u89c4\u5219\u5e76\u4e0d\u603b\u662f\u76f4\u89c2\u7684\uff0c\u4f46\u5728\u5b9e\u8df5\u4e2d\uff0c\u4f60\u53ea\u9700\u8981\u4e86\u89e3\u4e00\u4e9b\u57fa\u672c\u89c4\u5219\u5373\u53ef\u3002<\/p>\n<p>\u7406\u89e3\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\u6709\u52a9\u4e8e\u7f16\u5199\u6574\u6d01\u7684\u4ee3\u7801\uff0c\u8fd9\u662f\u73b0\u4ee3\u7f16\u7a0b\u7684\u65e2\u5b9a\u6807\u51c6\u3002\u7f16\u5199\u6574\u6d01\u7684\u4ee3\u7801\u610f\u5473\u7740\u7f16\u5199\u6613\u4e8e\u7406\u89e3\u548c\u7ef4\u62a4\u7684\u4ee3\u7801\u3002\u5728\u8fd0\u7b97\u7b26\u65b9\u9762\uff0c\u6574\u6d01\u4ee3\u7801\u7684\u8303\u5f0f\u610f\u5473\u7740\u5c3d\u91cf\u5c11\u4f7f\u7528\u8fd0\u7b97\u7b26\uff0c\u800c\u662f\u521b\u5efa\u5355\u72ec\u7684\u8bed\u53e5\uff0c\u800c\u4e0d\u662f\u5d4c\u5957\u548c\u7ec4\u5408\u8fd0\u7b97\u7b26\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u5e94\u907f\u514d\u4f7f\u7528\u50cf\u4e0b\u9762\u8fd9\u6837\u7684\u9648\u8ff0\uff0c\u56e0\u4e3a\u5b83\u4eec\u592a\u4ee4\u4eba\u56f0\u60d1\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">boolean isThisCleanCode <span class=\"token operator\">=<\/span> <span class=\"token operator\">!<\/span>true <span class=\"token operator\">||<\/span> <span class=\"token boolean\">false<\/span> <span class=\"token operator\">&amp;&amp;<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u5373\u4f7f\u4f60\u67e5\u9605\u64cd\u4f5c\u624b\u518c\uff0c\u4e5f\u53ef\u80fd\u65e0\u6cd5\u731c\u6d4b\u6700\u7ec8\u7ed3\u679c\uff08isThisCleanCode\u4e3a\u5047\uff09\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u6700\u91cd\u8981\u548c\u5e38\u7528\u7684\u4f18\u5148\u89c4\u5219\uff0c\u4ece\u5177\u6709\u6700\u9ad8\u4f18\u5148\u7ea7\u7684\u89c4\u5219\u5f00\u59cb\uff1a<\/p>\n<ul class=\"post-ul\">\n<li><strong>\u524d\u7f00\u548c\u540e\u7f00\u589e\u91cf\u4e0e\u51cf\u91cf\u8fd0\u7b97\u7b26\uff1a<\/strong>\u5b83\u4eec\u5177\u6709\u6700\u9ad8\u7684\u4f18\u5148\u7ea7\uff0c\u5e76\u5728\u4efb\u4f55\u5176\u4ed6\u8fd0\u7b97\u7b26\u4e4b\u524d\u751f\u6548\u3002<\/li>\n<li><strong>\u6570\u5b66\u8fd0\u7b97\u89c4\u5219\uff1a<\/strong>\u6240\u6709\u5728\u6570\u5b66\u4e2d\u6709\u6548\u7684\u89c4\u5219\u5728Java\u4e2d\u4e5f\u6709\u6548\u3002\u4f8b\u5982\uff0c\u9664\u6cd5 <code>\/<\/code> \u5177\u6709\u6bd4\u52a0\u6cd5 <code>+<\/code> \u66f4\u9ad8\u7684\u4f18\u5148\u7ea7\u3002\u62ec\u53f7\u53ef\u4ee5\u8986\u76d6\u4f18\u5148\u7ea7\uff1b\u4e5f\u5c31\u662f\u8bf4\uff0c\u4f60\u53ef\u4ee5\u7528\u62ec\u53f7\u5c06\u64cd\u4f5c\u5206\u7ec4\uff0c\u5b83\u4eec\u5c06\u4f18\u5148\u88ab\u8bc4\u4f30\u3002<\/li>\n<li><strong>\u76f8\u7b49\u548c\u5173\u7cfb\u8fd0\u7b97\u7b26\uff1a<\/strong>\u7531\u4e8e\u5b83\u4eec\u8bc4\u4f30\u76f8\u7b49\u6027\u6216\u5173\u7cfb\uff0c\u5b83\u4eec\u4e5f\u4f5c\u7528\u4e8e\u5176\u64cd\u4f5c\u6570\u7684\u6700\u7ec8\u503c\uff0c\u56e0\u6b64\u6240\u6709\u5176\u4ed6\u64cd\u4f5c\u90fd\u5fc5\u987b\u5b8c\u6210\u3002<\/li>\n<li><strong>\u903b\u8f91\u6216\u548c\u4e0e\u8fd0\u7b97\u7b26\uff08\u5305\u62ec\u77ed\u8def\uff09\uff1a<\/strong>\u7c7b\u4f3c\u4e8e\u4e09\u5143\u8fd0\u7b97\u7b26\uff0c\u5b83\u4eec\u90fd\u9700\u8981\u5176\u64cd\u4f5c\u6570\u7684\u6700\u7ec8\u503c\uff0c\u56e0\u6b64\u5b83\u4eec\u7684\u4f18\u5148\u7ea7\u8f83\u4f4e\u3002<\/li>\n<li><strong>\u4e09\u5143\u8fd0\u7b97\u7b26\uff1a<\/strong>\u4e09\u5143\u8fd0\u7b97\u7b26\u9700\u8981\u7b2c\u4e00\u4e2a\u64cd\u4f5c\u6570\u7684\u6700\u7ec8\u503c\u3002\u4e3a\u4e86\u5b9e\u73b0\u8fd9\u4e00\u70b9\uff0c\u6240\u6709\u5176\u4ed6\u64cd\u4f5c\u90fd\u5fc5\u987b\u5df2\u7ecf\u5b8c\u6210\u3002\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u4e09\u5143\u8fd0\u7b97\u7b26\u7684\u4f18\u5148\u7ea7\u5982\u6b64\u4e4b\u4f4e\u3002<\/li>\n<li><strong>\u8d4b\u503c\u8fd0\u7b97\u7b26\uff1a<\/strong>\u5b83\u4eec\u6700\u540e\u88ab\u8bc4\u4f30\uff0c\u4ee5\u4fbf\u6240\u6709\u5176\u4ed6\u64cd\u4f5c\u90fd\u5df2\u5b8c\u6210\uff0c\u5e76\u4e14\u6700\u7ec8\u7ed3\u679c\u53ef\u4ee5\u8d4b\u503c\u7ed9\u5de6\u4fa7\u7684\u64cd\u4f5c\u6570\u3002\u4f8b\u5982\uff0c\u60f3\u60f3\u4f60\u8fc4\u4eca\u4e3a\u6b62\u7528\u7b49\u53f7\u8d4b\u503c\u7684\u6bcf\u4e2a\u53d8\u91cf\u3002<\/li>\n<\/ul>\n<p>\u73b0\u5728\uff0c\u4f60\u5c06\u4f7f\u7528\u4e00\u9053\u6570\u5b66\u95ee\u9898\u6765\u63a2\u7d22\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">int x <span class=\"token operator\">=<\/span> <span class=\"token number\">1<\/span> + <span class=\"token number\">10<\/span> \/ <span class=\"token number\">2<\/span><span class=\"token punctuation\">;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u5f53\u4f60\u5c06\u4ee5\u4e0a\u4ee3\u7801\u7c98\u8d34\u5230jshell\u4e2d\u65f6\uff0c\u4f60\u5c06\u4f1a\u5f97\u5230\u4e0b\u9762\u7684\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">\u8f93\u51fa<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>x ==&gt; 6<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<\/div>\n<p>\u6839\u636e\u4e0a\u8ff0\u8f93\u51fa\uff0c<code>x<\/code> \u7684\u503c\u4e3a6\u3002\u8fd9\u662f\u56e0\u4e3a\u5df2\u7ecf\u5b8c\u6210\u4e86\u4ee5\u4e0b\u64cd\u4f5c\uff0c\u6309\u7167\u9012\u51cf\u7684\u4f18\u5148\u7ea7\u6392\u5217\uff1a<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\n<li>\u9996\u5148\u8ba1\u7b9710\u9664\u4ee52\uff0c\u7ed3\u679c\u4e3a5\u3002<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\n<li>\u7136\u540e\u5c06\u7b2c\u4e00\u6b65\u64cd\u4f5c\u7684\u7ed3\u679c\uff085\uff09\u52a01\uff0c\u5f97\u52306\u3002<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li>\u63a5\u7740\u8d4b\u503c\u64cd\u4f5c\u7b26\u5f00\u59cb\u6267\u884c\uff0c\u4f7f\u7528\u6700\u7ec8\u7ed3\u679c\uff086\uff09\u5c06\u5176\u8d4b\u7ed9\u53d8\u91cf <code>x<\/code>\u3002<\/li>\n<\/ol>\n<p>\u5c3d\u7ba1\u8fd9\u4e2a\u6570\u5b66\u65b9\u7a0b\u76f8\u5bf9\u6765\u8bf4\u5f88\u7b80\u5355\uff0c\u4f46\u4f60\u53ef\u4ee5\u901a\u8fc7\u589e\u52a0\u5197\u4f59\u5185\u5bb9\u5e76\u4f7f\u7528\u62ec\u53f7\u6765\u786e\u4fdd\u8fd0\u7b97\u7684\u4f18\u5148\u7ea7\u66f4\u5bb9\u6613\u7406\u89e3\u3002\u8003\u8651\u628a\u5b83\u6539\u5199\u6210\u8fd9\u6837\uff1a<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<ol>\n<li data-prefix=\"jshell&gt;\">int x <span class=\"token operator\">=<\/span> <span class=\"token number\">1<\/span> + <mark><span class=\"token punctuation\">(<\/span><\/mark><span class=\"token number\">10<\/span> \/ <span class=\"token number\">2<\/span><mark><span class=\"token punctuation\">)<\/span><\/mark><span class=\"token punctuation\">;<\/span><\/li>\n<\/ol>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>\u5f53\u4f60\u5c06\u4e0a\u8ff0\u5185\u5bb9\u7c98\u8d34\u5230jshell\u4e2d\u65f6\uff0c\u5c06\u6253\u5370\u51fa\u4e0e\u4e4b\u524d\u76f8\u540c\u7684\u7ed3\u679c\u3002<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<div class=\"secondary-code-label\" title=\"Output\">\u8f93\u51fa<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<p>x ==&gt; 6<\/p>\n<pre class=\"post-pre\"><code><\/code><\/pre>\n<\/div>\n<p>\u5728\u4e0a\u4e00\u4e2a\u793a\u4f8b\u4e2d\uff0c\u4f60\u6ca1\u6709\u901a\u8fc7\u5728 <code>10 \/ 2<\/code> \u5468\u56f4\u4f7f\u7528\u62ec\u53f7\u6765\u66f4\u6539\u4f18\u5148\u7ea7\u3002\u76f8\u53cd\uff0c\u5b83\u4eec\u7684\u76ee\u7684\u53ea\u662f\u4f7f\u62ec\u53f7\u5185\u7684\u64cd\u4f5c\u7684\u4f18\u5148\u7ea7\u66f4\u660e\u663e\u3002\u50cf\u8fd9\u6837\u4f7f\u7528\u62ec\u53f7\u6709\u52a9\u4e8e\u4f7f\u4f60\u7684\u4ee3\u7801\u66f4\u52a0\u6e05\u6670\u548c\u6613\u61c2\uff0c\u5c24\u5176\u662f\u5728\u64cd\u4f5c\u66f4\u52a0\u590d\u6742\u7684\u60c5\u51b5\u4e0b\u3002<\/p>\n<p>\u4f18\u5148\u89c4\u5219\u5f88\u6709\u8da3\uff0c\u82b1\u70b9\u65f6\u95f4\u5b66\u4e60\u5b83\u4eec\u662f\u4e2a\u597d\u4e3b\u610f\u3002\u7262\u8bb0\u4ee3\u7801\u7684\u6574\u6d01\u8303\u5f0f\uff0c\u4e0d\u8981\u8fdb\u884c\u4e0d\u5fc5\u8981\u7684\u5d4c\u5957\u548c\u64cd\u4f5c\u7b26\u7ec4\u5408\uff0c\u56e0\u4e3a\u8fd9\u88ab\u89c6\u4e3a\u4ee3\u7801\u4e0a\u7684\u5f31\u70b9\u3002<\/p>\n<h2>\u7ed3\u8bba<\/h2>\n<p>\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u4f60\u5b66\u4e60\u4e86Java\u4e2d\u7684\u4e3b\u8981\u8fd0\u7b97\u7b26\u3002\u4f60\u7f16\u5199\u4e86\u4e00\u4e9b\u6d4b\u8bd5\u4ee3\u7801\u7247\u6bb5\uff0c\u5176\u4e2d\u4f60\u770b\u5230\u4e86\u4e0e\u8fd0\u7b97\u7b26\u76f8\u5173\u7684\u4e00\u4e9b\u6700\u6709\u7528\u548c\u6709\u8da3\u7684\u573a\u666f\u3002\u4f60\u8fd8\u5b66\u4e60\u4e86\u7b80\u6d01\u4ee3\u7801\u7684\u539f\u5219\uff0c\u610f\u8bc6\u5230\u8fd0\u7b97\u7b26\u4e0d\u5e94\u8be5\u88ab\u4e0d\u5fc5\u8981\u5730\u8fc7\u5ea6\u4f7f\u7528\u3002<\/p>\n<p>\u60f3\u4e86\u89e3\u66f4\u591a\u5173\u4e8eJava\u7684\u5185\u5bb9\uff0c\u8bf7\u8bbf\u95ee\u6211\u4eec\u7684\u300aJava\u7f16\u7a0b\u6307\u5357\u300b\u7cfb\u5217\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7b80\u4ecb \u8fd0\u7b97\u7b26\u7531\u4e00\u4e2a\u6216\u591a\u4e2a\u7b26\u53f7\u7ec4\u5408\u800c\u6210\uff0c\u4f8b\u5982\u8457\u540d\u7684\u7b97\u672f\u8fd0\u7b97\u7b26\u51cf\u53f7\uff08-\uff09\u548c\u52a0\u53f7\uff08+\uff09\uff0c\u6216\u8005\u66f4\u9ad8\u7ea7\u7684instance [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[189,260,206,259,557],"class_list":["post-114","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-java","tag-260","tag-206","tag-259","tag-557"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Java\u8fd0\u7b97\u7b26\u8be6\u89e3\uff1a\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\u5e94\u7528 - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"\u6df1\u5165\u5b66\u4e60Java\u4e2d\u5404\u79cd\u8fd0\u7b97\u7b26\u7684\u4f7f\u7528\u65b9\u6cd5\u548c\u5e94\u7528\u573a\u666f\uff0c\u5305\u62ec\u7b97\u672f\u3001\u5173\u7cfb\u3001\u903b\u8f91\u3001\u4f4d\u3001\u8d4b\u503c\u548c\u4e09\u5143\u8fd0\u7b97\u7b26\u3002\u901a\u8fc7\u8be6\u7ec6\u7684\u89e3\u91ca\u548c\u4ee3\u7801\u793a\u4f8b\uff0c\u5e2e\u52a9\u60a8\u5168\u9762\u638c\u63e1Java\u8fd0\u7b97\u7b26\uff0c\u63d0\u5347\u7f16\u7a0b\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u5982\u4f55\u5728java\u4e2d\u4f7f\u7528\u8fd0\u7b97\u7b26\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java\u8fd0\u7b97\u7b26\u8be6\u89e3\uff1a\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\u5e94\u7528\" \/>\n<meta property=\"og:description\" content=\"\u6df1\u5165\u5b66\u4e60Java\u4e2d\u5404\u79cd\u8fd0\u7b97\u7b26\u7684\u4f7f\u7528\u65b9\u6cd5\u548c\u5e94\u7528\u573a\u666f\uff0c\u5305\u62ec\u7b97\u672f\u3001\u5173\u7cfb\u3001\u903b\u8f91\u3001\u4f4d\u3001\u8d4b\u503c\u548c\u4e09\u5143\u8fd0\u7b97\u7b26\u3002\u901a\u8fc7\u8be6\u7ec6\u7684\u89e3\u91ca\u548c\u4ee3\u7801\u793a\u4f8b\uff0c\u5e2e\u52a9\u60a8\u5168\u9762\u638c\u63e1Java\u8fd0\u7b97\u7b26\uff0c\u63d0\u5347\u7f16\u7a0b\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u5982\u4f55\u5728java\u4e2d\u4f7f\u7528\u8fd0\u7b97\u7b26\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-16T14:50:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-31T16:10:58+00:00\" \/>\n<meta name=\"author\" content=\"\u6e05, \u626c\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u6e05, \u626c\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e5%9c%a8java%e4%b8%ad%e4%bd%bf%e7%94%a8%e8%bf%90%e7%ae%97%e7%ac%a6\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e5%9c%a8java%e4%b8%ad%e4%bd%bf%e7%94%a8%e8%bf%90%e7%ae%97%e7%ac%a6\/\",\"name\":\"Java\u8fd0\u7b97\u7b26\u8be6\u89e3\uff1a\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\u5e94\u7528 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-07-16T14:50:27+00:00\",\"dateModified\":\"2025-07-31T16:10:58+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461\"},\"description\":\"\u6df1\u5165\u5b66\u4e60Java\u4e2d\u5404\u79cd\u8fd0\u7b97\u7b26\u7684\u4f7f\u7528\u65b9\u6cd5\u548c\u5e94\u7528\u573a\u666f\uff0c\u5305\u62ec\u7b97\u672f\u3001\u5173\u7cfb\u3001\u903b\u8f91\u3001\u4f4d\u3001\u8d4b\u503c\u548c\u4e09\u5143\u8fd0\u7b97\u7b26\u3002\u901a\u8fc7\u8be6\u7ec6\u7684\u89e3\u91ca\u548c\u4ee3\u7801\u793a\u4f8b\uff0c\u5e2e\u52a9\u60a8\u5168\u9762\u638c\u63e1Java\u8fd0\u7b97\u7b26\uff0c\u63d0\u5347\u7f16\u7a0b\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e5%9c%a8java%e4%b8%ad%e4%bd%bf%e7%94%a8%e8%bf%90%e7%ae%97%e7%ac%a6\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e5%9c%a8java%e4%b8%ad%e4%bd%bf%e7%94%a8%e8%bf%90%e7%ae%97%e7%ac%a6\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e5%9c%a8java%e4%b8%ad%e4%bd%bf%e7%94%a8%e8%bf%90%e7%ae%97%e7%ac%a6\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\u8fd0\u7b97\u7b26\u8be6\u89e3\uff1a\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\u5e94\u7528\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461\",\"name\":\"\u6e05, \u626c\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g\",\"caption\":\"\u6e05, \u626c\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyang\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e5%9c%a8java%e4%b8%ad%e4%bd%bf%e7%94%a8%e8%bf%90%e7%ae%97%e7%ac%a6\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Java\u8fd0\u7b97\u7b26\u8be6\u89e3\uff1a\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\u5e94\u7528 - Blog - Silicon Cloud","description":"\u6df1\u5165\u5b66\u4e60Java\u4e2d\u5404\u79cd\u8fd0\u7b97\u7b26\u7684\u4f7f\u7528\u65b9\u6cd5\u548c\u5e94\u7528\u573a\u666f\uff0c\u5305\u62ec\u7b97\u672f\u3001\u5173\u7cfb\u3001\u903b\u8f91\u3001\u4f4d\u3001\u8d4b\u503c\u548c\u4e09\u5143\u8fd0\u7b97\u7b26\u3002\u901a\u8fc7\u8be6\u7ec6\u7684\u89e3\u91ca\u548c\u4ee3\u7801\u793a\u4f8b\uff0c\u5e2e\u52a9\u60a8\u5168\u9762\u638c\u63e1Java\u8fd0\u7b97\u7b26\uff0c\u63d0\u5347\u7f16\u7a0b\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u5982\u4f55\u5728java\u4e2d\u4f7f\u7528\u8fd0\u7b97\u7b26\/","og_locale":"zh_CN","og_type":"article","og_title":"Java\u8fd0\u7b97\u7b26\u8be6\u89e3\uff1a\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\u5e94\u7528","og_description":"\u6df1\u5165\u5b66\u4e60Java\u4e2d\u5404\u79cd\u8fd0\u7b97\u7b26\u7684\u4f7f\u7528\u65b9\u6cd5\u548c\u5e94\u7528\u573a\u666f\uff0c\u5305\u62ec\u7b97\u672f\u3001\u5173\u7cfb\u3001\u903b\u8f91\u3001\u4f4d\u3001\u8d4b\u503c\u548c\u4e09\u5143\u8fd0\u7b97\u7b26\u3002\u901a\u8fc7\u8be6\u7ec6\u7684\u89e3\u91ca\u548c\u4ee3\u7801\u793a\u4f8b\uff0c\u5e2e\u52a9\u60a8\u5168\u9762\u638c\u63e1Java\u8fd0\u7b97\u7b26\uff0c\u63d0\u5347\u7f16\u7a0b\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u5982\u4f55\u5728java\u4e2d\u4f7f\u7528\u8fd0\u7b97\u7b26\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-07-16T14:50:27+00:00","article_modified_time":"2025-07-31T16:10:58+00:00","author":"\u6e05, \u626c","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u6e05, \u626c","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e5%9c%a8java%e4%b8%ad%e4%bd%bf%e7%94%a8%e8%bf%90%e7%ae%97%e7%ac%a6\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e5%9c%a8java%e4%b8%ad%e4%bd%bf%e7%94%a8%e8%bf%90%e7%ae%97%e7%ac%a6\/","name":"Java\u8fd0\u7b97\u7b26\u8be6\u89e3\uff1a\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\u5e94\u7528 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-07-16T14:50:27+00:00","dateModified":"2025-07-31T16:10:58+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461"},"description":"\u6df1\u5165\u5b66\u4e60Java\u4e2d\u5404\u79cd\u8fd0\u7b97\u7b26\u7684\u4f7f\u7528\u65b9\u6cd5\u548c\u5e94\u7528\u573a\u666f\uff0c\u5305\u62ec\u7b97\u672f\u3001\u5173\u7cfb\u3001\u903b\u8f91\u3001\u4f4d\u3001\u8d4b\u503c\u548c\u4e09\u5143\u8fd0\u7b97\u7b26\u3002\u901a\u8fc7\u8be6\u7ec6\u7684\u89e3\u91ca\u548c\u4ee3\u7801\u793a\u4f8b\uff0c\u5e2e\u52a9\u60a8\u5168\u9762\u638c\u63e1Java\u8fd0\u7b97\u7b26\uff0c\u63d0\u5347\u7f16\u7a0b\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e5%9c%a8java%e4%b8%ad%e4%bd%bf%e7%94%a8%e8%bf%90%e7%ae%97%e7%ac%a6\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e5%9c%a8java%e4%b8%ad%e4%bd%bf%e7%94%a8%e8%bf%90%e7%ae%97%e7%ac%a6\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e5%9c%a8java%e4%b8%ad%e4%bd%bf%e7%94%a8%e8%bf%90%e7%ae%97%e7%ac%a6\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"Java\u8fd0\u7b97\u7b26\u8be6\u89e3\uff1a\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\u5e94\u7528"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461","name":"\u6e05, \u626c","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g","caption":"\u6e05, \u626c"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyang\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%a6%82%e4%bd%95%e5%9c%a8java%e4%b8%ad%e4%bd%bf%e7%94%a8%e8%bf%90%e7%ae%97%e7%ac%a6\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/114","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=114"}],"version-history":[{"count":4,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/114\/revisions"}],"predecessor-version":[{"id":109585,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/114\/revisions\/109585"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}