{"id":411,"date":"2023-05-28T01:47:58","date_gmt":"2023-05-27T17:47:58","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/?p=411"},"modified":"2023-05-28T01:48:03","modified_gmt":"2023-05-27T17:48:03","slug":"%e8%af%a6%e8%a7%a3-23-%e7%a7%8d%e8%ae%be%e8%ae%a1%e6%a8%a1%e5%bc%8f%ef%bc%88%e5%a4%9a%e5%9b%be-%e4%bb%a3%e7%a0%81%ef%bc%89","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/java\/%e8%af%a6%e8%a7%a3-23-%e7%a7%8d%e8%ae%be%e8%ae%a1%e6%a8%a1%e5%bc%8f%ef%bc%88%e5%a4%9a%e5%9b%be-%e4%bb%a3%e7%a0%81%ef%bc%89\/","title":{"rendered":"\u8be6\u89e3 23 \u79cd\u8bbe\u8ba1\u6a21\u5f0f\uff08\u591a\u56fe + \u4ee3\u7801\uff09"},"content":{"rendered":"<div class=\"wxsyncmain\">\n<section class=\"appmsg_card_context wx_profile_card js_card\" style=\"font-size: 0px; text-align: center; white-space: normal; margin-bottom: 0px;\"><\/section>\n<section class=\"mp_profile_iframe_wrp\"><\/section>\n<section style=\"margin-bottom: 0px; outline: 0px; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; white-space: normal; background-color: #ffffff;\"><strong style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 16px;\">\u76ee\u5f55<\/span><\/strong><\/section>\n<section style=\"padding: 10px; outline: 0px; white-space: normal; background-color: #ffffff; color: black; line-height: 1.6; letter-spacing: 0px; word-break: break-word; text-align: left; font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, 'PingFang SC', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif; font-size: 14px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\">\n<ul class=\"list-paddingleft-1\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px; outline: 0px; list-style-type: square;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\">\u521b\u5efa\u578b\u6a21\u5f0f<\/section>\n<\/li>\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\">\u7ed3\u6784\u578b\u6a21\u5f0f<\/section>\n<\/li>\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\">\u884c\u4e3a\u578b\u6a21\u5f0f<\/section>\n<\/li>\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\">\u603b\u7ed3<\/section>\n<\/li>\n<\/ul>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; width: 657px; text-align: center;\" data-width=\"100%\">\n<section style=\"outline: 0px; display: inline-block; width: auto;\">\n<section style=\"margin-right: auto; margin-bottom: -12px; margin-left: auto; outline: 0px; width: 45px; background-color: #fefefe; transform: translateZ(10px);\"><img decoding=\"async\" class=\"__bg_gif lazyload\" style=\"outline: 0px; display: block; width: 45px; visibility: visible !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005349628.gif\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-ratio=\"1\" data-w=\"100\" data-width=\"100%\" \/><noscript><img decoding=\"async\" class=\"__bg_gif\" style=\"outline: 0px; display: block; width: 45px; visibility: visible !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005349628.gif\" data-ratio=\"1\" data-w=\"100\" data-width=\"100%\" \/><\/noscript><\/section>\n<section style=\"outline: 0px; display: inline-block; width: auto; height: auto;\">\n<section style=\"outline: 0px; height: 40px; border: 1px solid #666666;\"><\/section>\n<section style=\"margin: -37px -3px -3px 3px; outline: 0px;\">\n<section style=\"padding-right: 15px; padding-left: 15px; outline: 0px; display: inline-block; height: 40px; line-height: 40px; width: 60px; border: 1px solid #ff7480;\" data-width=\"100%\">\n<p style=\"outline: 0px;\">\u524d\u8a00<\/p>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u4e00\u76f4\u60f3\u5199\u4e00\u7bc7\u4ecb\u7ecd\u8bbe\u8ba1\u6a21\u5f0f\u7684\u6587\u7ae0\uff0c\u8ba9\u8bfb\u8005\u53ef\u4ee5\u5f88\u5feb\u770b\u5b8c\uff0c\u800c\u4e14\u4e00\u770b\u5c31\u61c2\uff0c\u770b\u61c2\u5c31\u4f1a\u7528\uff0c\u540c\u65f6\u4e0d\u4f1a\u5c06\u5404\u4e2a\u6a21\u5f0f\u641e\u6df7\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"outline: 0px;\">\u8bbe\u8ba1\u6a21\u5f0f<\/strong>\u662f\u5bf9\u5927\u5bb6\u5b9e\u9645\u5de5\u4f5c\u4e2d\u5199\u7684\u5404\u79cd\u4ee3\u7801\u8fdb\u884c\u9ad8\u5c42\u6b21\u62bd\u8c61\u7684\u603b\u7ed3\uff0c\u5176\u4e2d\u6700\u51fa\u540d\u7684\u5f53\u5c5e\u00a0<em style=\"outline: 0px;\">Gang of Four<\/em>\u00a0(<em style=\"outline: 0px;\">GoF<\/em>) \u7684\u5206\u7c7b\u4e86\uff0c\u4ed6\u4eec\u5c06\u8bbe\u8ba1\u6a21\u5f0f\u5206\u7c7b\u4e3a 23 \u79cd\u7ecf\u5178\u7684\u6a21\u5f0f\uff0c\u6839\u636e\u7528\u9014\u6211\u4eec\u53c8\u53ef\u4ee5\u5206\u4e3a\u4e09\u5927\u7c7b\uff0c\u5206\u522b\u4e3a\u521b\u5efa\u578b\u6a21\u5f0f\u3001\u7ed3\u6784\u578b\u6a21\u5f0f\u548c\u884c\u4e3a\u578b\u6a21\u5f0f\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6709\u4e00\u4e9b\u91cd\u8981\u7684\u8bbe\u8ba1\u539f\u5219\u5728\u5f00\u7bc7\u548c\u5927\u5bb6\u5206\u4eab\u4e0b\uff0c\u8fd9\u4e9b\u539f\u5219\u5c06\u8d2f\u901a\u5168\u6587\uff1a<\/p>\n<ol class=\"list-paddingleft-1\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px; outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\">\u9762\u5411\u63a5\u53e3\u7f16\u7a0b\uff0c\u800c\u4e0d\u662f\u9762\u5411\u5b9e\u73b0\u3002\u8fd9\u4e2a\u5f88\u91cd\u8981\uff0c\u4e5f\u662f\u4f18\u96c5\u7684\u3001\u53ef\u6269\u5c55\u7684\u4ee3\u7801\u7684\u7b2c\u4e00\u6b65\uff0c\u8fd9\u5c31\u4e0d\u9700\u8981\u591a\u8bf4\u4e86\u5427\u3002<\/section>\n<\/li>\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\">\u804c\u8d23\u5355\u4e00\u539f\u5219\u3002\u6bcf\u4e2a\u7c7b\u90fd\u5e94\u8be5\u53ea\u6709\u4e00\u4e2a\u5355\u4e00\u7684\u529f\u80fd\uff0c\u5e76\u4e14\u8be5\u529f\u80fd\u5e94\u8be5\u7531\u8fd9\u4e2a\u7c7b\u5b8c\u5168\u5c01\u88c5\u8d77\u6765\u3002<\/section>\n<\/li>\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\">\u5bf9\u4fee\u6539\u5173\u95ed\uff0c\u5bf9\u6269\u5c55\u5f00\u653e\u3002\u5bf9\u4fee\u6539\u5173\u95ed\u662f\u8bf4\uff0c\u6211\u4eec\u8f9b\u8f9b\u82e6\u82e6\u52a0\u73ed\u5199\u51fa\u6765\u7684\u4ee3\u7801\uff0c\u8be5\u5b9e\u73b0\u7684\u529f\u80fd\u548c\u8be5\u4fee\u590d\u7684 bug \u90fd\u5b8c\u6210\u4e86\uff0c\u522b\u4eba\u53ef\u4e0d\u80fd\u8bf4\u6539\u5c31\u6539\uff1b\u5bf9\u6269\u5c55\u5f00\u653e\u5c31\u6bd4\u8f83\u597d\u7406\u89e3\u4e86\uff0c\u4e5f\u5c31\u662f\u8bf4\u5728\u6211\u4eec\u5199\u597d\u7684\u4ee3\u7801\u57fa\u7840\u4e0a\uff0c\u5f88\u5bb9\u6613\u5b9e\u73b0\u6269\u5c55\u3002<\/section>\n<\/li>\n<\/ol>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"outline: 0px;\">\u521b\u5efa\u578b\u6a21\u5f0f\u6bd4\u8f83\u7b80\u5355\uff0c\u4f46\u662f\u4f1a\u6bd4\u8f83\u6ca1\u6709\u610f\u601d\uff0c\u7ed3\u6784\u578b\u548c\u884c\u4e3a\u578b\u6bd4\u8f83\u6709\u610f\u601d\u3002<\/strong><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"outline: 0px;\">\u00a0<\/strong><\/p>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<blockquote style=\"margin: 5px auto; padding-top: 0px; padding-left: 0px; outline: 0px; color: #4499e7; font-size: 16px; line-height: 25.6px; border: 0px none #4499e7;\">\n<section style=\"margin-right: auto; margin-left: auto; outline: 0px; border-color: #4499e7;\">\n<section style=\"margin-right: auto; margin-left: auto; outline: 0px; border-color: #4499e7;\">\n<blockquote style=\"margin: 5px auto; padding-top: 0px; padding-left: 0px; outline: 0px; color: var(--weui-fg-1); border: 0px none #4499e7;\">\n<section style=\"margin-right: auto; margin-left: auto; outline: 0px; text-align: center; border-color: #4499e7;\">\n<section style=\"margin-right: auto; margin-bottom: -38px; margin-left: auto; padding-right: 15px; padding-left: 15px; outline: 0px; display: inline-block; background-color: #4499e7; border-color: #4499e7;\">\n<p style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; color: #4499e7; border-color: #4499e7;\"><span style=\"outline: 0px; font-family: Arial, Helvetica, sans-serif;\"><strong style=\"outline: 0px;\"><span style=\"outline: 0px; border-color: #4499e7; color: #ffffff; font-size: 16px;\">\u521b\u5efa\u578b\u6a21\u5f0f<\/span><\/strong><\/span><\/p>\n<\/section>\n<section style=\"margin: -40px 25px 50px; outline: 0px; border-color: #4499e7;\">\n<section style=\"margin-top: 3px; padding-top: 10px; padding-bottom: 10px; outline: 0px; display: inline-block; width: 495px; color: #4499e7; float: left; border-color: #4499e7;\">\n<section style=\"margin-top: 1em; outline: 0px; clear: both; border: 0px none #4499e7;\">\n<section style=\"margin-bottom: -3px; outline: 0px; float: right; border-color: #4499e7; width: 6px; border-radius: 50%; background-color: #4499e7; height: 6px !important;\"><\/section>\n<section style=\"margin-bottom: -2px; outline: 0px; text-align: left; border-color: #4499e7; width: 6px; border-radius: 50%; background-color: #4499e7; height: 6px !important;\"><\/section>\n<section style=\"margin-top: -20px; outline: 0px; text-decoration: inherit; border-color: #4499e7;\">\n<section style=\"outline: 0px; border-top: 1px solid #4499e7; width: 495px; float: left; border-right-color: #4499e7; border-bottom-color: #4499e7; border-left-color: #4499e7;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/blockquote>\n<\/section>\n<\/section>\n<\/blockquote>\n<\/section>\n<p style=\"outline: 0px;\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u521b\u5efa\u578b\u6a21\u5f0f\u7684\u4f5c\u7528\u5c31\u662f\u521b\u5efa\u5bf9\u8c61\uff0c\u8bf4\u5230\u521b\u5efa\u4e00\u4e2a\u5bf9\u8c61\uff0c\u6700\u719f\u6089\u7684\u5c31\u662f new \u4e00\u4e2a\u5bf9\u8c61\uff0c\u7136\u540e set \u76f8\u5173\u5c5e\u6027\u3002\u4f46\u662f\uff0c\u5728\u5f88\u591a\u573a\u666f\u4e0b\uff0c\u6211\u4eec\u9700\u8981\u7ed9\u5ba2\u6237\u7aef\u63d0\u4f9b\u66f4\u52a0\u53cb\u597d\u7684\u521b\u5efa\u5bf9\u8c61\u7684\u65b9\u5f0f\uff0c\u5c24\u5176\u662f\u90a3\u79cd\u6211\u4eec\u5b9a\u4e49\u4e86\u7c7b\uff0c\u4f46\u662f\u9700\u8981\u63d0\u4f9b\u7ed9\u5176\u4ed6\u5f00\u53d1\u8005\u7528\u7684\u65f6\u5019\u3002<\/p>\n<h3 style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><\/h3>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px; border: 0px none initial;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; display: inline-block;\">\n<section style=\"padding-right: 10px; padding-left: 10px; outline: 0px; font-size: 16px; color: #494949;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u7b80\u5355\u5de5\u5382\u6a21\u5f0f<\/span><\/p>\n<\/section>\n<section style=\"margin-top: -10px; outline: 0px; background-color: #fcb42b; height: 8px; color: #ffffff;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">\u548c\u540d\u5b57\u4e00\u6837\u7b80\u5355\uff0c\u975e\u5e38\u7b80\u5355\uff0c\u76f4\u63a5\u4e0a\u4ee3\u7801\u5427\uff1a<\/span><\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">FoodFactory<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0Food\u00a0<span style=\"outline: 0px; line-height: 26px;\">makeFood<\/span><span style=\"outline: 0px; line-height: 26px;\">(String\u00a0name)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">if<\/span>\u00a0(name.equals(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"noodle\"<\/span>))\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Food\u00a0noodle\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0LanZhouNoodle();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0noodle.addSpicy(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"more\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0noodle;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">else<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">if<\/span>\u00a0(name.equals(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"chicken\"<\/span>))\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Food\u00a0chicken\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0HuangMenChicken();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0chicken.addCondiment(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"potato\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0chicken;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">else<\/span>\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">null<\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><em style=\"outline: 0px;\">\u5176\u4e2d\uff0cLanZhouNoodle \u548c HuangMenChicken \u90fd\u7ee7\u627f\u81ea Food\u3002<\/em><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u7b80\u5355\u5730\u8bf4\uff0c\u7b80\u5355\u5de5\u5382\u6a21\u5f0f\u901a\u5e38\u5c31\u662f\u8fd9\u6837\uff0c\u4e00\u4e2a\u5de5\u5382\u7c7b XxxFactory\uff0c\u91cc\u9762\u6709\u4e00\u4e2a\u9759\u6001\u65b9\u6cd5\uff0c\u6839\u636e\u6211\u4eec\u4e0d\u540c\u7684\u53c2\u6570\uff0c\u8fd4\u56de\u4e0d\u540c\u7684\u6d3e\u751f\u81ea\u540c\u4e00\u4e2a\u7236\u7c7b\uff08\u6216\u5b9e\u73b0\u540c\u4e00\u63a5\u53e3\uff09\u7684\u5b9e\u4f8b\u5bf9\u8c61\u3002<\/p>\n<blockquote style=\"margin-top: 20px; margin-bottom: 20px; padding: 10px 10px 10px 20px; outline: 0px; border-left-color: rgba(0, 0, 0, 0.65); color: #6a737d; font-size: 0.9em; border-top: none; border-bottom: none; overflow: auto; border-right: 1px solid rgba(0, 0, 0, 0.65); background: #f9f9f9;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; font-size: 14px; color: black; line-height: 26px;\">\u6211\u4eec\u5f3a\u8c03<strong style=\"outline: 0px;\">\u804c\u8d23\u5355\u4e00<\/strong>\u00a0\u539f\u5219\uff0c\u4e00\u4e2a\u7c7b\u53ea\u63d0\u4f9b\u4e00\u79cd\u529f\u80fd\uff0cFoodFactory \u7684\u529f\u80fd\u5c31\u662f\u53ea\u8981\u8d1f\u8d23\u751f\u4ea7\u5404\u79cd Food\u3002<\/p>\n<\/blockquote>\n<h3 style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><\/h3>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px; border: 0px none initial;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; display: inline-block;\">\n<section style=\"padding-right: 10px; padding-left: 10px; outline: 0px; font-size: 16px; color: #494949;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u5de5\u5382\u6a21\u5f0f<\/span><\/p>\n<\/section>\n<section style=\"margin-top: -10px; outline: 0px; background-color: #fcb42b; height: 8px; color: #ffffff;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">\u7b80\u5355\u5de5\u5382\u6a21\u5f0f\u5f88\u7b80\u5355\uff0c\u5982\u679c\u5b83\u80fd\u6ee1\u8db3\u6211\u4eec\u7684\u9700\u8981\uff0c\u6211\u89c9\u5f97\u5c31\u4e0d\u8981\u6298\u817e\u4e86\u3002\u4e4b\u6240\u4ee5\u9700\u8981\u5f15\u5165\u5de5\u5382\u6a21\u5f0f\uff0c\u662f\u56e0\u4e3a\u6211\u4eec\u5f80\u5f80\u9700\u8981\u4f7f\u7528\u4e24\u4e2a\u6216\u4e24\u4e2a\u4ee5\u4e0a\u7684\u5de5\u5382\u3002<\/span><\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">interface<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">FoodFactory<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\">Food\u00a0<span style=\"outline: 0px; line-height: 26px;\">makeFood<\/span><span style=\"outline: 0px; line-height: 26px;\">(String\u00a0name)<\/span><\/span>;<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">ChineseFoodFactory<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">implements<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">FoodFactory<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #9b9b9b; line-height: 26px;\">@Override<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0Food\u00a0<span style=\"outline: 0px; line-height: 26px;\">makeFood<\/span><span style=\"outline: 0px; line-height: 26px;\">(String\u00a0name)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">if<\/span>\u00a0(name.equals(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"A\"<\/span>))\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0ChineseFoodA();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">else<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">if<\/span>\u00a0(name.equals(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"B\"<\/span>))\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0ChineseFoodB();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">else<\/span>\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">null<\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">AmericanFoodFactory<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">implements<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">FoodFactory<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #9b9b9b; line-height: 26px;\">@Override<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0Food\u00a0<span style=\"outline: 0px; line-height: 26px;\">makeFood<\/span><span style=\"outline: 0px; line-height: 26px;\">(String\u00a0name)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">if<\/span>\u00a0(name.equals(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"A\"<\/span>))\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0AmericanFoodA();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">else<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">if<\/span>\u00a0(name.equals(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"B\"<\/span>))\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0AmericanFoodB();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">else<\/span>\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">null<\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5176\u4e2d\uff0cChineseFoodA\u3001ChineseFoodB\u3001AmericanFoodA\u3001AmericanFoodB \u90fd\u6d3e\u751f\u81ea Food\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5ba2\u6237\u7aef\u8c03\u7528\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">APP<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">main<\/span><span style=\"outline: 0px; line-height: 26px;\">(String[]\u00a0args)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5148\u9009\u62e9\u4e00\u4e2a\u5177\u4f53\u7684\u5de5\u5382<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0FoodFactory\u00a0factory\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0ChineseFoodFactory();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u7531\u7b2c\u4e00\u6b65\u7684\u5de5\u5382\u4ea7\u751f\u5177\u4f53\u7684\u5bf9\u8c61\uff0c\u4e0d\u540c\u7684\u5de5\u5382\u9020\u51fa\u4e0d\u4e00\u6837\u7684\u5bf9\u8c61<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Food\u00a0food\u00a0=\u00a0factory.makeFood(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"A\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u867d\u7136\u90fd\u662f\u8c03\u7528 makeFood(\"A\") \u00a0\u5236\u4f5c A \u7c7b\u98df\u7269\uff0c\u4f46\u662f\uff0c\u4e0d\u540c\u7684\u5de5\u5382\u751f\u4ea7\u51fa\u6765\u7684\u5b8c\u5168\u4e0d\u4e00\u6837\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u7b2c\u4e00\u6b65\uff0c\u6211\u4eec\u9700\u8981\u9009\u53d6\u5408\u9002\u7684\u5de5\u5382\uff0c\u7136\u540e\u7b2c\u4e8c\u6b65\u57fa\u672c\u4e0a\u548c\u7b80\u5355\u5de5\u5382\u4e00\u6837\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"outline: 0px;\">\u6838\u5fc3\u5728\u4e8e\uff0c\u6211\u4eec\u9700\u8981\u5728\u7b2c\u4e00\u6b65\u9009\u597d\u6211\u4eec\u9700\u8981\u7684\u5de5\u5382<\/strong>\u00a0\u3002\u6bd4\u5982\uff0c\u6211\u4eec\u6709 LogFactory \u63a5\u53e3\uff0c\u5b9e\u73b0\u7c7b\u6709 FileLogFactory \u548c KafkaLogFactory\uff0c\u5206\u522b\u5bf9\u5e94\u5c06\u65e5\u5fd7\u5199\u5165\u6587\u4ef6\u548c\u5199\u5165 Kafka \u4e2d\uff0c\u663e\u7136\uff0c\u6211\u4eec\u5ba2\u6237\u7aef\u7b2c\u4e00\u6b65\u5c31\u9700\u8981\u51b3\u5b9a\u5230\u5e95\u8981\u5b9e\u4f8b\u5316 FileLogFactory \u8fd8\u662f KafkaLogFactory\uff0c\u8fd9\u5c06\u51b3\u5b9a\u4e4b\u540e\u7684\u6240\u6709\u7684\u64cd\u4f5c\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u867d\u7136\u7b80\u5355\uff0c\u4e0d\u8fc7\u6211\u4e5f\u628a\u6240\u6709\u7684\u6784\u4ef6\u90fd\u753b\u5230\u4e00\u5f20\u56fe\u4e0a\uff0c\u8fd9\u6837\u8bfb\u8005\u770b\u7740\u6bd4\u8f83\u6e05\u6670\uff1a<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005350226.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-ratio=\"0.7481481481481481\" data-type=\"png\" data-w=\"1080\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005350226.png\" data-ratio=\"0.7481481481481481\" data-type=\"png\" data-w=\"1080\" \/><\/noscript><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<h3 style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><\/h3>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px; border: 0px none initial;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; display: inline-block;\">\n<section style=\"padding-right: 10px; padding-left: 10px; outline: 0px; font-size: 16px; color: #494949;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u62bd\u8c61\u5de5\u5382\u6a21\u5f0f<\/span><\/p>\n<\/section>\n<section style=\"margin-top: -10px; outline: 0px; background-color: #fcb42b; height: 8px; color: #ffffff;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">\u5f53\u6d89\u53ca\u5230<\/span><strong style=\"outline: 0px; letter-spacing: 0px;\">\u4ea7\u54c1\u65cf<\/strong><span style=\"outline: 0px; letter-spacing: 0px;\">\u00a0\u7684\u65f6\u5019\uff0c\u5c31\u9700\u8981\u5f15\u5165\u62bd\u8c61\u5de5\u5382\u6a21\u5f0f\u4e86\u3002<\/span><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u4e00\u4e2a\u7ecf\u5178\u7684\u4f8b\u5b50\u662f\u9020\u4e00\u53f0\u7535\u8111\u3002\u6211\u4eec\u5148\u4e0d\u5f15\u5165\u62bd\u8c61\u5de5\u5382\u6a21\u5f0f\uff0c\u770b\u770b\u600e\u4e48\u5b9e\u73b0\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u56e0\u4e3a\u7535\u8111\u662f\u7531\u8bb8\u591a\u7684\u6784\u4ef6\u7ec4\u6210\u7684\uff0c\u6211\u4eec\u5c06 CPU \u548c\u4e3b\u677f\u8fdb\u884c\u62bd\u8c61\uff0c\u7136\u540e CPU \u7531 CPUFactory \u751f\u4ea7\uff0c\u4e3b\u677f\u7531 MainBoardFactory \u751f\u4ea7\uff0c\u7136\u540e\uff0c\u6211\u4eec\u518d\u5c06 CPU \u548c\u4e3b\u677f\u642d\u914d\u8d77\u6765\u7ec4\u5408\u5728\u4e00\u8d77\uff0c\u5982\u4e0b\u56fe\uff1a<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005353211.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-ratio=\"0.612037037037037\" data-type=\"png\" data-w=\"1080\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005353211.png\" data-ratio=\"0.612037037037037\" data-type=\"png\" data-w=\"1080\" \/><\/noscript><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8fd9\u4e2a\u65f6\u5019\u7684\u5ba2\u6237\u7aef\u8c03\u7528\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5f97\u5230\u00a0Intel\u00a0\u7684\u00a0CPU<\/span><br style=\"outline: 0px;\" \/>CPUFactory\u00a0cpuFactory\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0IntelCPUFactory();<br style=\"outline: 0px;\" \/>CPU\u00a0cpu\u00a0=\u00a0intelCPUFactory.makeCPU();<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5f97\u5230\u00a0AMD\u00a0\u7684\u4e3b\u677f<\/span><br style=\"outline: 0px;\" \/>MainBoardFactory\u00a0mainBoardFactory\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0AmdMainBoardFactory();<br style=\"outline: 0px;\" \/>MainBoard\u00a0mainBoard\u00a0=\u00a0mainBoardFactory.make();<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u7ec4\u88c5\u00a0CPU\u00a0\u548c\u4e3b\u677f<\/span><br style=\"outline: 0px;\" \/>Computer\u00a0computer\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Computer(cpu,\u00a0mainBoard);<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5355\u72ec\u770b CPU \u5de5\u5382\u548c\u4e3b\u677f\u5de5\u5382\uff0c\u5b83\u4eec\u5206\u522b\u662f\u524d\u9762\u6211\u4eec\u8bf4\u7684<strong style=\"outline: 0px;\">\u5de5\u5382\u6a21\u5f0f<\/strong>\u00a0\u3002\u8fd9\u79cd\u65b9\u5f0f\u4e5f\u5bb9\u6613\u6269\u5c55\uff0c\u56e0\u4e3a\u8981\u7ed9\u7535\u8111\u52a0\u786c\u76d8\u7684\u8bdd\uff0c\u53ea\u9700\u8981\u52a0\u4e00\u4e2a HardDiskFactory \u548c\u76f8\u5e94\u7684\u5b9e\u73b0\u5373\u53ef\uff0c\u4e0d\u9700\u8981\u4fee\u6539\u73b0\u6709\u7684\u5de5\u5382\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u4f46\u662f\uff0c\u8fd9\u79cd\u65b9\u5f0f\u6709\u4e00\u4e2a\u95ee\u9898\uff0c\u90a3\u5c31\u662f\u5982\u679c\u00a0<strong style=\"outline: 0px;\">Intel \u5bb6\u4ea7\u7684 CPU \u548c AMD \u4ea7\u7684\u4e3b\u677f\u4e0d\u80fd\u517c\u5bb9\u4f7f\u7528<\/strong>\u00a0\uff0c\u90a3\u4e48\u8fd9\u4ee3\u7801\u5c31\u5bb9\u6613\u51fa\u9519\uff0c\u56e0\u4e3a\u5ba2\u6237\u7aef\u5e76\u4e0d\u77e5\u9053\u5b83\u4eec\u4e0d\u517c\u5bb9\uff0c\u4e5f\u5c31\u4f1a\u9519\u8bef\u5730\u51fa\u73b0\u968f\u610f\u7ec4\u5408\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u4e0b\u9762\u5c31\u662f\u6211\u4eec\u8981\u8bf4\u7684<strong style=\"outline: 0px;\">\u4ea7\u54c1\u65cf<\/strong>\u00a0\u7684\u6982\u5ff5\uff0c\u5b83\u4ee3\u8868\u4e86\u7ec4\u6210\u67d0\u4e2a\u4ea7\u54c1\u7684\u4e00\u7cfb\u5217\u9644\u4ef6\u7684\u96c6\u5408\uff1a<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; outline: 0px; display: flex; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><figcaption style=\"margin-top: 5px; outline: 0px; text-align: center; color: #888888; font-size: 12px;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005357327.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-ratio=\"0.39814814814814814\" data-type=\"png\" data-w=\"1080\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005357327.png\" data-ratio=\"0.39814814814814814\" data-type=\"png\" data-w=\"1080\" \/><\/noscript><\/figcaption><\/figure>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5f53\u6d89\u53ca\u5230\u8fd9\u79cd\u4ea7\u54c1\u65cf\u7684\u95ee\u9898\u7684\u65f6\u5019\uff0c\u5c31\u9700\u8981\u62bd\u8c61\u5de5\u5382\u6a21\u5f0f\u6765\u652f\u6301\u4e86\u3002\u6211\u4eec\u4e0d\u518d\u5b9a\u4e49 CPU \u5de5\u5382\u3001\u4e3b\u677f\u5de5\u5382\u3001\u786c\u76d8\u5de5\u5382\u3001\u663e\u793a\u5c4f\u5de5\u5382\u7b49\u7b49\uff0c\u6211\u4eec\u76f4\u63a5\u5b9a\u4e49\u7535\u8111\u5de5\u5382\uff0c\u6bcf\u4e2a\u7535\u8111\u5de5\u5382\u8d1f\u8d23\u751f\u4ea7\u6240\u6709\u7684\u8bbe\u5907\uff0c\u8fd9\u6837\u80fd\u4fdd\u8bc1\u80af\u5b9a\u4e0d\u5b58\u5728\u517c\u5bb9\u95ee\u9898\u3002<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; outline: 0px; display: flex; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><figcaption style=\"margin-top: 5px; outline: 0px; text-align: center; color: #888888; font-size: 12px;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005359799.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-ratio=\"0.5703703703703704\" data-type=\"png\" data-w=\"1080\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005359799.png\" data-ratio=\"0.5703703703703704\" data-type=\"png\" data-w=\"1080\" \/><\/noscript><\/figcaption><\/figure>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8fd9\u4e2a\u65f6\u5019\uff0c\u5bf9\u4e8e\u5ba2\u6237\u7aef\u6765\u8bf4\uff0c\u4e0d\u518d\u9700\u8981\u5355\u72ec\u6311\u9009 CPU\u5382\u5546\u3001\u4e3b\u677f\u5382\u5546\u3001\u786c\u76d8\u5382\u5546\u7b49\uff0c\u76f4\u63a5\u9009\u62e9\u4e00\u5bb6\u54c1\u724c\u5de5\u5382\uff0c\u54c1\u724c\u5de5\u5382\u4f1a\u8d1f\u8d23\u751f\u4ea7\u6240\u6709\u7684\u4e1c\u897f\uff0c\u800c\u4e14\u80fd\u4fdd\u8bc1\u80af\u5b9a\u662f\u517c\u5bb9\u53ef\u7528\u7684\u3002<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">main<\/span><span style=\"outline: 0px; line-height: 26px;\">(String[]\u00a0args)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u7b2c\u4e00\u6b65\u5c31\u8981\u9009\u5b9a\u4e00\u4e2a\u201c\u5927\u5382\u201d<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0ComputerFactory\u00a0cf\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0AmdFactory();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u4ece\u8fd9\u4e2a\u5927\u5382\u9020\u00a0CPU<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0CPU\u00a0cpu\u00a0=\u00a0cf.makeCPU();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u4ece\u8fd9\u4e2a\u5927\u5382\u9020\u4e3b\u677f<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0MainBoard\u00a0board\u00a0=\u00a0cf.makeMainBoard();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u4ece\u8fd9\u4e2a\u5927\u5382\u9020\u786c\u76d8<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0HardDisk\u00a0hardDisk\u00a0=\u00a0cf.makeHardDisk();<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5c06\u540c\u4e00\u4e2a\u5382\u5b50\u51fa\u6765\u7684\u00a0CPU\u3001\u4e3b\u677f\u3001\u786c\u76d8\u7ec4\u88c5\u5728\u4e00\u8d77<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0Computer\u00a0result\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Computer(cpu,\u00a0board,\u00a0hardDisk);<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5f53\u7136\uff0c\u62bd\u8c61\u5de5\u5382\u7684\u95ee\u9898\u4e5f\u662f\u663e\u800c\u6613\u89c1\u7684\uff0c\u6bd4\u5982\u6211\u4eec\u8981\u52a0\u4e2a\u663e\u793a\u5668\uff0c\u5c31\u9700\u8981\u4fee\u6539\u6240\u6709\u7684\u5de5\u5382\uff0c\u7ed9\u6240\u6709\u7684\u5de5\u5382\u90fd\u52a0\u4e0a\u5236\u9020\u663e\u793a\u5668\u7684\u65b9\u6cd5\u3002\u8fd9\u6709\u70b9\u8fdd\u53cd\u4e86<strong style=\"outline: 0px;\">\u5bf9\u4fee\u6539\u5173\u95ed\uff0c\u5bf9\u6269\u5c55\u5f00\u653e<\/strong>\u00a0\u8fd9\u4e2a\u8bbe\u8ba1\u539f\u5219\u3002<\/p>\n<h3 style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><\/h3>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px; border: 0px none initial;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; display: inline-block;\">\n<section style=\"padding-right: 10px; padding-left: 10px; outline: 0px; font-size: 16px; color: #494949;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u5355\u4f8b\u6a21\u5f0f<\/span><\/p>\n<\/section>\n<section style=\"margin-top: -10px; outline: 0px; background-color: #fcb42b; height: 8px; color: #ffffff;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">\u5355\u4f8b\u6a21\u5f0f\u7528\u5f97\u6700\u591a\uff0c\u9519\u5f97\u6700\u591a\u3002<\/span><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u997f\u6c49\u6a21\u5f0f\u6700\u7b80\u5355\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Singleton<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u9996\u5148\uff0c\u5c06\u00a0new\u00a0Singleton()\u00a0\u5835\u6b7b<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">Singleton<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{};<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u521b\u5efa\u79c1\u6709\u9759\u6001\u5b9e\u4f8b\uff0c\u610f\u5473\u7740\u8fd9\u4e2a\u7c7b\u7b2c\u4e00\u6b21\u4f7f\u7528\u7684\u65f6\u5019\u5c31\u4f1a\u8fdb\u884c\u521b\u5efa<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0Singleton\u00a0instance\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Singleton();<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0Singleton\u00a0<span style=\"outline: 0px; line-height: 26px;\">getInstance<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0instance;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u778e\u5199\u4e00\u4e2a\u9759\u6001\u65b9\u6cd5\u3002\u8fd9\u91cc\u60f3\u8bf4\u7684\u662f\uff0c\u5982\u679c\u6211\u4eec\u53ea\u662f\u8981\u8c03\u7528 Singleton.getDate(...)\uff0c<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u672c\u6765\u662f\u4e0d\u60f3\u8981\u751f\u6210\u00a0Singleton\u00a0\u5b9e\u4f8b\u7684\uff0c\u4e0d\u8fc7\u6ca1\u529e\u6cd5\uff0c\u5df2\u7ecf\u751f\u6210\u4e86<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0Date\u00a0<span style=\"outline: 0px; line-height: 26px;\">getDate<\/span><span style=\"outline: 0px; line-height: 26px;\">(String\u00a0mode)<\/span>\u00a0<\/span>{<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Date();}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<blockquote style=\"margin-top: 20px; margin-bottom: 20px; padding: 10px 10px 10px 20px; outline: 0px; border-left-color: rgba(0, 0, 0, 0.65); color: #6a737d; font-size: 0.9em; border-top: none; border-bottom: none; overflow: auto; border-right: 1px solid rgba(0, 0, 0, 0.65); background: #f9f9f9;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; font-size: 14px; color: black; line-height: 26px;\">\u5f88\u591a\u4eba\u90fd\u80fd\u8bf4\u51fa\u997f\u6c49\u6a21\u5f0f\u7684\u7f3a\u70b9\uff0c\u53ef\u662f\u6211\u89c9\u5f97\u751f\u4ea7\u8fc7\u7a0b\u4e2d\uff0c\u5f88\u5c11\u78b0\u5230\u8fd9\u79cd\u60c5\u51b5\uff1a\u4f60\u5b9a\u4e49\u4e86\u4e00\u4e2a\u5355\u4f8b\u7684\u7c7b\uff0c\u4e0d\u9700\u8981\u5176\u5b9e\u4f8b\uff0c\u53ef\u662f\u4f60\u5374\u628a\u4e00\u4e2a\u6216\u51e0\u4e2a\u4f60\u4f1a\u7528\u5230\u7684\u9759\u6001\u65b9\u6cd5\u585e\u5230\u8fd9\u4e2a\u7c7b\u4e2d\u3002<\/p>\n<\/blockquote>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u9971\u6c49\u6a21\u5f0f\u6700\u5bb9\u6613\u51fa\u9519\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Singleton<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u9996\u5148\uff0c\u4e5f\u662f\u5148\u5835\u6b7b\u00a0new\u00a0Singleton()\u00a0\u8fd9\u6761\u8def<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">Singleton<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u548c\u997f\u6c49\u6a21\u5f0f\u76f8\u6bd4\uff0c\u8fd9\u8fb9\u4e0d\u9700\u8981\u5148\u5b9e\u4f8b\u5316\u51fa\u6765\uff0c\u6ce8\u610f\u8fd9\u91cc\u7684\u00a0volatile\uff0c\u5b83\u662f\u5fc5\u987b\u7684<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">volatile<\/span>\u00a0Singleton\u00a0instance\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">null<\/span>;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0Singleton\u00a0<span style=\"outline: 0px; line-height: 26px;\">getInstance<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">if<\/span>\u00a0(instance\u00a0==\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">null<\/span>)\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u52a0\u9501<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">synchronized<\/span>\u00a0(Singleton<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\">.<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>)\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u8fd9\u4e00\u6b21\u5224\u65ad\u4e5f\u662f\u5fc5\u987b\u7684\uff0c\u4e0d\u7136\u4f1a\u6709\u5e76\u53d1\u95ee\u9898<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">if<\/span>\u00a0(instance\u00a0==\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">null<\/span>)\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0instance\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Singleton();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0instance;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<blockquote style=\"margin-top: 20px; margin-bottom: 20px; padding: 10px 10px 10px 20px; outline: 0px; border-left-color: rgba(0, 0, 0, 0.65); color: #6a737d; font-size: 0.9em; border-top: none; border-bottom: none; overflow: auto; border-right: 1px solid rgba(0, 0, 0, 0.65); background: #f9f9f9;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; font-size: 14px; color: black; line-height: 26px;\">\u53cc\u91cd\u68c0\u67e5\uff0c\u6307\u7684\u662f\u4e24\u6b21\u68c0\u67e5 instance \u662f\u5426\u4e3a null\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; font-size: 14px; color: black; line-height: 26px;\">volatile \u5728\u8fd9\u91cc\u662f\u9700\u8981\u7684\uff0c\u5e0c\u671b\u80fd\u5f15\u8d77\u8bfb\u8005\u7684\u5173\u6ce8\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; font-size: 14px; color: black; line-height: 26px;\">\u5f88\u591a\u4eba\u4e0d\u77e5\u9053\u600e\u4e48\u5199\uff0c\u76f4\u63a5\u5c31\u5728 getInstance() \u65b9\u6cd5\u7b7e\u540d\u4e0a\u52a0\u4e0a synchronized\uff0c\u8fd9\u5c31\u4e0d\u591a\u8bf4\u4e86\uff0c\u6027\u80fd\u592a\u5dee\u3002<\/p>\n<\/blockquote>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5d4c\u5957\u7c7b\u6700\u7ecf\u5178\uff0c\u4ee5\u540e\u5927\u5bb6\u5c31\u7528\u5b83\u5427\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Singleton3<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">Singleton3<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u4e3b\u8981\u662f\u4f7f\u7528\u4e86\u00a0\u5d4c\u5957\u7c7b\u53ef\u4ee5\u8bbf\u95ee\u5916\u90e8\u7c7b\u7684\u9759\u6001\u5c5e\u6027\u548c\u9759\u6001\u65b9\u6cd5\u00a0\u7684\u7279\u6027<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Holder<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0Singleton3\u00a0instance\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Singleton3();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0Singleton3\u00a0<span style=\"outline: 0px; line-height: 26px;\">getInstance<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0Holder.instance;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<blockquote style=\"margin-top: 20px; margin-bottom: 20px; padding: 10px 10px 10px 20px; outline: 0px; border-left-color: rgba(0, 0, 0, 0.65); color: #6a737d; font-size: 0.9em; border-top: none; border-bottom: none; overflow: auto; border-right: 1px solid rgba(0, 0, 0, 0.65); background: #f9f9f9;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; font-size: 14px; color: black; line-height: 26px;\">\u6ce8\u610f\uff0c\u5f88\u591a\u4eba\u90fd\u4f1a\u628a\u8fd9\u4e2a<strong style=\"outline: 0px;\">\u5d4c\u5957\u7c7b<\/strong>\u00a0\u8bf4\u6210\u662f<strong style=\"outline: 0px;\">\u9759\u6001\u5185\u90e8\u7c7b<\/strong>\u00a0\uff0c\u4e25\u683c\u5730\u8bf4\uff0c\u5185\u90e8\u7c7b\u548c\u5d4c\u5957\u7c7b\u662f\u4e0d\u4e00\u6837\u7684\uff0c\u5b83\u4eec\u80fd\u8bbf\u95ee\u7684\u5916\u90e8\u7c7b\u6743\u9650\u4e5f\u662f\u4e0d\u4e00\u6837\u7684\u3002<\/p>\n<\/blockquote>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6700\u540e\uff0c\u6211\u4eec\u8bf4\u4e00\u4e0b\u679a\u4e3e\uff0c\u679a\u4e3e\u5f88\u7279\u6b8a\uff0c\u5b83\u5728\u7c7b\u52a0\u8f7d\u7684\u65f6\u5019\u4f1a\u521d\u59cb\u5316\u91cc\u9762\u7684\u6240\u6709\u7684\u5b9e\u4f8b\uff0c\u800c\u4e14 JVM \u4fdd\u8bc1\u4e86\u5b83\u4eec\u4e0d\u4f1a\u518d\u88ab\u5b9e\u4f8b\u5316\uff0c\u6240\u4ee5\u5b83\u5929\u751f\u5c31\u662f\u5355\u4f8b\u7684\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u867d\u7136\u6211\u4eec\u5e73\u65f6\u5f88\u5c11\u770b\u5230\u7528\u679a\u4e3e\u6765\u5b9e\u73b0\u5355\u4f8b\uff0c\u4f46\u662f\u5728 RxJava \u7684\u6e90\u7801\u4e2d\uff0c\u6709\u5f88\u591a\u5730\u65b9\u90fd\u7528\u4e86\u679a\u4e3e\u6765\u5b9e\u73b0\u5355\u4f8b\u3002<\/p>\n<h3 style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><\/h3>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px; border: 0px none initial;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; display: inline-block;\">\n<section style=\"padding-right: 10px; padding-left: 10px; outline: 0px; font-size: 16px; color: #494949;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u5efa\u9020\u8005\u6a21\u5f0f<\/span><\/p>\n<\/section>\n<section style=\"margin-top: -10px; outline: 0px; background-color: #fcb42b; height: 8px; color: #ffffff;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">\u7ecf\u5e38\u78b0\u89c1\u7684 XxxBuilder \u7684\u7c7b\uff0c\u901a\u5e38\u90fd\u662f\u5efa\u9020\u8005\u6a21\u5f0f\u7684\u4ea7\u7269\u3002\u5efa\u9020\u8005\u6a21\u5f0f\u5176\u5b9e\u6709\u5f88\u591a\u7684\u53d8\u79cd\uff0c\u4f46\u662f\u5bf9\u4e8e\u5ba2\u6237\u7aef\u6765\u8bf4\uff0c\u6211\u4eec\u7684\u4f7f\u7528\u901a\u5e38\u90fd\u662f\u4e00\u4e2a\u6a21\u5f0f\u7684\uff1a<\/span><\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\">Food\u00a0food\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0FoodBuilder().a().b().c().build();<br style=\"outline: 0px;\" \/>Food\u00a0food\u00a0=\u00a0Food.builder().a().b().c().build();<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5957\u8def\u5c31\u662f\u5148 new \u4e00\u4e2a Builder\uff0c\u7136\u540e\u53ef\u4ee5\u94fe\u5f0f\u5730\u8c03\u7528\u4e00\u5806\u65b9\u6cd5\uff0c\u6700\u540e\u518d\u8c03\u7528\u4e00\u6b21 build() \u65b9\u6cd5\uff0c\u6211\u4eec\u9700\u8981\u7684\u5bf9\u8c61\u5c31\u6709\u4e86\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6765\u4e00\u4e2a\u4e2d\u89c4\u4e2d\u77e9\u7684\u5efa\u9020\u8005\u6a21\u5f0f\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">User<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u4e0b\u9762\u662f\u201c\u4e00\u5806\u201d\u7684\u5c5e\u6027<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0String\u00a0name;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0String\u00a0password;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0String\u00a0nickName;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0age;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u6784\u9020\u65b9\u6cd5\u79c1\u6709\u5316\uff0c\u4e0d\u7136\u5ba2\u6237\u7aef\u5c31\u4f1a\u76f4\u63a5\u8c03\u7528\u6784\u9020\u65b9\u6cd5\u4e86<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">User<\/span><span style=\"outline: 0px; line-height: 26px;\">(String\u00a0name,\u00a0String\u00a0password,\u00a0String\u00a0nickName,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0age)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.name\u00a0=\u00a0name;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.password\u00a0=\u00a0password;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.nickName\u00a0=\u00a0nickName;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.age\u00a0=\u00a0age;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u9759\u6001\u65b9\u6cd5\uff0c\u7528\u4e8e\u751f\u6210\u4e00\u4e2a\u00a0Builder\uff0c\u8fd9\u4e2a\u4e0d\u4e00\u5b9a\u8981\u6709\uff0c\u4e0d\u8fc7\u5199\u8fd9\u4e2a\u65b9\u6cd5\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u4e60\u60ef\uff0c<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u6709\u4e9b\u4ee3\u7801\u8981\u6c42\u522b\u4eba\u5199\u00a0new\u00a0User.UserBuilder().a()...build()\u00a0\u770b\u4e0a\u53bb\u5c31\u6ca1\u90a3\u4e48\u597d<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0UserBuilder\u00a0<span style=\"outline: 0px; line-height: 26px;\">builder<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0UserBuilder();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">UserBuilder<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u4e0b\u9762\u662f\u548c\u00a0User\u00a0\u4e00\u6a21\u4e00\u6837\u7684\u4e00\u5806\u5c5e\u6027<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0String\u00a0\u00a0name;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0String\u00a0password;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0String\u00a0nickName;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0age;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">UserBuilder<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u94fe\u5f0f\u8c03\u7528\u8bbe\u7f6e\u5404\u4e2a\u5c5e\u6027\u503c\uff0c\u8fd4\u56de\u00a0this\uff0c\u5373\u00a0UserBuilder<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0UserBuilder\u00a0<span style=\"outline: 0px; line-height: 26px;\">name<\/span><span style=\"outline: 0px; line-height: 26px;\">(String\u00a0name)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.name\u00a0=\u00a0name;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0UserBuilder\u00a0<span style=\"outline: 0px; line-height: 26px;\">password<\/span><span style=\"outline: 0px; line-height: 26px;\">(String\u00a0password)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.password\u00a0=\u00a0password;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0UserBuilder\u00a0<span style=\"outline: 0px; line-height: 26px;\">nickName<\/span><span style=\"outline: 0px; line-height: 26px;\">(String\u00a0nickName)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.nickName\u00a0=\u00a0nickName;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0UserBuilder\u00a0<span style=\"outline: 0px; line-height: 26px;\">age<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0age)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.age\u00a0=\u00a0age;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/ build()\u00a0\u65b9\u6cd5\u8d1f\u8d23\u5c06 UserBuilder \u4e2d\u8bbe\u7f6e\u597d\u7684\u5c5e\u6027\u201c\u590d\u5236\u201d\u5230 User \u4e2d\u3002<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5f53\u7136\uff0c\u53ef\u4ee5\u5728\u00a0\u201c\u590d\u5236\u201d\u00a0\u4e4b\u524d\u505a\u70b9\u68c0\u9a8c<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0User\u00a0<span style=\"outline: 0px; line-height: 26px;\">build<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">if<\/span>\u00a0(name\u00a0==\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">null<\/span>\u00a0||\u00a0password\u00a0==\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">null<\/span>)\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">throw<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0RuntimeException(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u7528\u6237\u540d\u548c\u5bc6\u7801\u5fc5\u586b\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">if<\/span>\u00a0(age\u00a0&lt;=\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\">0<\/span>\u00a0||\u00a0age\u00a0&gt;=\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\">150<\/span>)\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">throw<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0RuntimeException(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u5e74\u9f84\u4e0d\u5408\u6cd5\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u8fd8\u53ef\u4ee5\u505a\u8d4b\u4e88\u201d\u9ed8\u8ba4\u503c\u201c\u7684\u529f\u80fd<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">if<\/span>\u00a0(nickName\u00a0==\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">null<\/span>)\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0nickName\u00a0=\u00a0name;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0User(name,\u00a0password,\u00a0nickName,\u00a0age);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6838\u5fc3\u662f\uff1a\u5148\u628a\u6240\u6709\u7684\u5c5e\u6027\u90fd\u8bbe\u7f6e\u7ed9 Builder\uff0c\u7136\u540e build() \u65b9\u6cd5\u7684\u65f6\u5019\uff0c\u5c06\u8fd9\u4e9b\u5c5e\u6027<strong style=\"outline: 0px;\">\u590d\u5236<\/strong>\u00a0\u7ed9\u5b9e\u9645\u4ea7\u751f\u7684\u5bf9\u8c61\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u770b\u770b\u5ba2\u6237\u7aef\u7684\u8c03\u7528\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">APP<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">main<\/span><span style=\"outline: 0px; line-height: 26px;\">(String[]\u00a0args)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0User\u00a0d\u00a0=\u00a0User.builder()<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0.name(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"foo\"<\/span>)<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0.password(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"pAss12345\"<\/span>)<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0.age(<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\">25<\/span>)<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0.build();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8bf4\u5b9e\u8bdd\uff0c\u5efa\u9020\u8005\u6a21\u5f0f\u7684<strong style=\"outline: 0px;\">\u94fe\u5f0f<\/strong>\u00a0\u5199\u6cd5\u5f88\u5438\u5f15\u4eba\uff0c\u4f46\u662f\uff0c\u591a\u5199\u4e86\u5f88\u591a\u201c\u65e0\u7528\u201d\u7684 builder \u7684\u4ee3\u7801\uff0c\u611f\u89c9\u8fd9\u4e2a\u6a21\u5f0f\u6ca1\u4ec0\u4e48\u7528\u3002\u4e0d\u8fc7\uff0c\u5f53\u5c5e\u6027\u5f88\u591a\uff0c\u800c\u4e14\u6709\u4e9b\u5fc5\u586b\uff0c\u6709\u4e9b\u9009\u586b\u7684\u65f6\u5019\uff0c\u8fd9\u4e2a\u6a21\u5f0f\u4f1a\u4f7f\u4ee3\u7801\u6e05\u6670\u5f88\u591a\u3002\u6211\u4eec\u53ef\u4ee5\u5728\u00a0<strong style=\"outline: 0px;\">Builder \u7684\u6784\u9020\u65b9\u6cd5<\/strong>\u00a0\u4e2d\u5f3a\u5236\u8ba9\u8c03\u7528\u8005\u63d0\u4f9b\u5fc5\u586b\u5b57\u6bb5\uff0c\u8fd8\u6709\uff0c\u5728 build() \u65b9\u6cd5\u4e2d\u6821\u9a8c\u5404\u4e2a\u53c2\u6570\u6bd4\u5728 User \u7684\u6784\u9020\u65b9\u6cd5\u4e2d\u6821\u9a8c\uff0c\u4ee3\u7801\u8981\u4f18\u96c5\u4e00\u4e9b\u3002<\/p>\n<blockquote style=\"margin-top: 20px; margin-bottom: 20px; padding: 10px 10px 10px 20px; outline: 0px; border-left-color: rgba(0, 0, 0, 0.65); color: #6a737d; font-size: 0.9em; border-top: none; border-bottom: none; overflow: auto; border-right: 1px solid rgba(0, 0, 0, 0.65); background: #f9f9f9;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; font-size: 14px; color: black; line-height: 26px;\">\u9898\u5916\u8bdd\uff0c\u5f3a\u70c8\u5efa\u8bae\u8bfb\u8005\u4f7f\u7528 lombok\uff0c\u7528\u4e86 lombok \u4ee5\u540e\uff0c\u4e0a\u9762\u7684\u4e00\u5927\u5806\u4ee3\u7801\u4f1a\u53d8\u6210\u5982\u4e0b\u8fd9\u6837:<\/p>\n<\/blockquote>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #9b9b9b; line-height: 26px;\">@Builderclass<\/span>\u00a0User\u00a0{\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0String\u00a0\u00a0name;\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0String\u00a0password;\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0String\u00a0nickName;\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0age;}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<blockquote style=\"margin-top: 20px; margin-bottom: 20px; padding: 10px 10px 10px 20px; outline: 0px; border-left-color: rgba(0, 0, 0, 0.65); color: #6a737d; font-size: 0.9em; border-top: none; border-bottom: none; overflow: auto; border-right: 1px solid rgba(0, 0, 0, 0.65); background: #f9f9f9;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; font-size: 14px; color: black; line-height: 26px;\">\u600e\u4e48\u6837\uff0c\u7701\u4e0b\u6765\u7684\u65f6\u95f4\u662f\u4e0d\u662f\u53c8\u53ef\u4ee5\u5e72\u70b9\u522b\u7684\u4e86\u3002<\/p>\n<\/blockquote>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5f53\u7136\uff0c\u5982\u679c\u4f60\u53ea\u662f\u60f3\u8981\u94fe\u5f0f\u5199\u6cd5\uff0c\u4e0d\u60f3\u8981\u5efa\u9020\u8005\u6a21\u5f0f\uff0c\u6709\u4e2a\u5f88\u7b80\u5355\u7684\u529e\u6cd5\uff0cUser \u7684 getter \u65b9\u6cd5\u4e0d\u53d8\uff0c\u6240\u6709\u7684 setter \u65b9\u6cd5\u90fd\u8ba9\u5176\u00a0<strong style=\"outline: 0px;\">return this<\/strong>\u00a0\u5c31\u53ef\u4ee5\u4e86\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u50cf\u4e0b\u9762\u8fd9\u6837\u8c03\u7528\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\">User\u00a0user\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0User().setName(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\"<\/span>).setPassword(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\"<\/span>).setAge(<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\">20<\/span>);<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<blockquote style=\"margin-top: 20px; margin-bottom: 20px; padding: 10px 10px 10px 20px; outline: 0px; border-left-color: rgba(0, 0, 0, 0.65); color: #6a737d; font-size: 0.9em; border-top: none; border-bottom: none; overflow: auto; border-right: 1px solid rgba(0, 0, 0, 0.65); background: #f9f9f9;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; font-size: 14px; color: black; line-height: 26px;\">\u5f88\u591a\u4eba\u662f\u8fd9\u4e48\u7528\u7684\uff0c\u4f46\u662f\u7b14\u8005\u89c9\u5f97\u5176\u5b9e\u8fd9\u79cd\u5199\u6cd5\u975e\u5e38\u5730\u4e0d\u4f18\u96c5\uff0c\u4e0d\u662f\u5f88\u63a8\u8350\u4f7f\u7528\u3002<\/p>\n<\/blockquote>\n<h3 style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><\/h3>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px; border: 0px none initial;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; display: inline-block;\">\n<section style=\"padding-right: 10px; padding-left: 10px; outline: 0px; font-size: 16px; color: #494949;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u539f\u578b\u6a21\u5f0f<\/span><\/p>\n<\/section>\n<section style=\"margin-top: -10px; outline: 0px; background-color: #fcb42b; height: 8px; color: #ffffff;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">\u8fd9\u662f\u6211\u8981\u8bf4\u7684\u521b\u5efa\u578b\u6a21\u5f0f\u7684\u6700\u540e\u4e00\u4e2a\u8bbe\u8ba1\u6a21\u5f0f\u4e86\u3002<\/span><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u539f\u578b\u6a21\u5f0f\u5f88\u7b80\u5355\uff1a\u6709\u4e00\u4e2a\u539f\u578b<strong style=\"outline: 0px;\">\u5b9e\u4f8b<\/strong>\u00a0\uff0c\u57fa\u4e8e\u8fd9\u4e2a\u539f\u578b\u5b9e\u4f8b\u4ea7\u751f\u65b0\u7684\u5b9e\u4f8b\uff0c\u4e5f\u5c31\u662f\u201c\u514b\u9686\u201d\u4e86\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">Object \u7c7b\u4e2d\u6709\u4e00\u4e2a clone() \u65b9\u6cd5\uff0c\u5b83\u7528\u4e8e\u751f\u6210\u4e00\u4e2a\u65b0\u7684\u5bf9\u8c61\uff0c\u5f53\u7136\uff0c\u5982\u679c\u6211\u4eec\u8981\u8c03\u7528\u8fd9\u4e2a\u65b9\u6cd5\uff0cjava \u8981\u6c42\u6211\u4eec\u7684\u7c7b\u5fc5\u987b\u5148<strong style=\"outline: 0px;\">\u5b9e\u73b0 Cloneable \u63a5\u53e3<\/strong>\u00a0\uff0c\u6b64\u63a5\u53e3\u6ca1\u6709\u5b9a\u4e49\u4efb\u4f55\u65b9\u6cd5\uff0c\u4f46\u662f\u4e0d\u8fd9\u4e48\u505a\u7684\u8bdd\uff0c\u5728 clone() \u7684\u65f6\u5019\uff0c\u4f1a\u629b\u51fa CloneNotSupportedException \u5f02\u5e38\u3002<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">protected<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">native<\/span>\u00a0Object\u00a0<span style=\"outline: 0px; line-height: 26px;\">clone<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">throws<\/span>\u00a0CloneNotSupportedException<\/span>;<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<blockquote style=\"margin-top: 20px; margin-bottom: 20px; padding: 10px 10px 10px 20px; outline: 0px; border-left-color: rgba(0, 0, 0, 0.65); color: #6a737d; font-size: 0.9em; border-top: none; border-bottom: none; overflow: auto; border-right: 1px solid rgba(0, 0, 0, 0.65); background: #f9f9f9;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; font-size: 14px; color: black; line-height: 26px;\">java \u7684\u514b\u9686\u662f\u6d45\u514b\u9686\uff0c\u78b0\u5230\u5bf9\u8c61\u5f15\u7528\u7684\u65f6\u5019\uff0c\u514b\u9686\u51fa\u6765\u7684\u5bf9\u8c61\u548c\u539f\u5bf9\u8c61\u4e2d\u7684\u5f15\u7528\u5c06\u6307\u5411\u540c\u4e00\u4e2a\u5bf9\u8c61\u3002\u901a\u5e38\u5b9e\u73b0\u6df1\u514b\u9686\u7684\u65b9\u6cd5\u662f\u5c06\u5bf9\u8c61\u8fdb\u884c\u5e8f\u5217\u5316\uff0c\u7136\u540e\u518d\u8fdb\u884c\u53cd\u5e8f\u5217\u5316\u3002<\/p>\n<\/blockquote>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u539f\u578b\u6a21\u5f0f\u4e86\u89e3\u5230\u8fd9\u91cc\u6211\u89c9\u5f97\u5c31\u591f\u4e86\uff0c\u5404\u79cd\u53d8\u7740\u6cd5\u5b50\u8bf4\u8fd9\u79cd\u4ee3\u7801\u6216\u90a3\u79cd\u4ee3\u7801\u662f\u539f\u578b\u6a21\u5f0f\uff0c\u6ca1\u4ec0\u4e48\u610f\u4e49\u3002<\/p>\n<h3 style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><\/h3>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px; border: 0px none initial;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; display: inline-block;\">\n<section style=\"padding-right: 10px; padding-left: 10px; outline: 0px; font-size: 16px; color: #494949;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u521b\u5efa\u578b\u6a21\u5f0f\u603b\u7ed3<\/span><\/p>\n<\/section>\n<section style=\"margin-top: -10px; outline: 0px; background-color: #fcb42b; height: 8px; color: #ffffff;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">\u521b\u5efa\u578b\u6a21\u5f0f\u603b\u4f53\u4e0a\u6bd4\u8f83\u7b80\u5355\uff0c\u5b83\u4eec\u7684\u4f5c\u7528\u5c31\u662f\u4e3a\u4e86\u4ea7\u751f\u5b9e\u4f8b\u5bf9\u8c61\uff0c\u7b97\u662f\u5404\u79cd\u5de5\u4f5c\u7684\u7b2c\u4e00\u6b65\u4e86\uff0c\u56e0\u4e3a\u6211\u4eec\u5199\u7684\u662f<\/span><strong style=\"outline: 0px; letter-spacing: 0px;\">\u9762\u5411\u5bf9\u8c61<\/strong><span style=\"outline: 0px; letter-spacing: 0px;\">\u00a0\u7684\u4ee3\u7801\uff0c\u6240\u4ee5\u6211\u4eec\u7b2c\u4e00\u6b65\u5f53\u7136\u662f\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u5bf9\u8c61\u4e86\u3002<\/span><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u7b80\u5355\u5de5\u5382\u6a21\u5f0f\u6700\u7b80\u5355\uff1b\u5de5\u5382\u6a21\u5f0f\u5728\u7b80\u5355\u5de5\u5382\u6a21\u5f0f\u7684\u57fa\u7840\u4e0a\u589e\u52a0\u4e86\u9009\u62e9\u5de5\u5382\u7684\u7ef4\u5ea6\uff0c\u9700\u8981\u7b2c\u4e00\u6b65\u9009\u62e9\u5408\u9002\u7684\u5de5\u5382\uff1b\u62bd\u8c61\u5de5\u5382\u6a21\u5f0f\u6709\u4ea7\u54c1\u65cf\u7684\u6982\u5ff5\uff0c\u5982\u679c\u5404\u4e2a\u4ea7\u54c1\u662f\u5b58\u5728\u517c\u5bb9\u6027\u95ee\u9898\u7684\uff0c\u5c31\u8981\u7528\u62bd\u8c61\u5de5\u5382\u6a21\u5f0f\u3002\u5355\u4f8b\u6a21\u5f0f\u5c31\u4e0d\u8bf4\u4e86\uff0c\u4e3a\u4e86\u4fdd\u8bc1\u5168\u5c40\u4f7f\u7528\u7684\u662f\u540c\u4e00\u5bf9\u8c61\uff0c\u4e00\u65b9\u9762\u662f\u5b89\u5168\u6027\u8003\u8651\uff0c\u4e00\u65b9\u9762\u662f\u4e3a\u4e86\u8282\u7701\u8d44\u6e90\uff1b\u5efa\u9020\u8005\u6a21\u5f0f\u4e13\u95e8\u5bf9\u4ed8\u5c5e\u6027\u5f88\u591a\u7684\u90a3\u79cd\u7c7b\uff0c\u4e3a\u4e86\u8ba9\u4ee3\u7801\u66f4\u4f18\u7f8e\uff1b\u539f\u578b\u6a21\u5f0f\u7528\u5f97\u6700\u5c11\uff0c\u4e86\u89e3\u548c Object \u7c7b\u4e2d\u7684 clone() \u65b9\u6cd5\u76f8\u5173\u7684\u77e5\u8bc6\u5373\u53ef\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<blockquote style=\"margin: 5px auto; padding-top: 0px; padding-left: 0px; outline: 0px; color: #4499e7; font-size: 16px; line-height: 25.6px; border: 0px none #4499e7;\">\n<section style=\"margin-right: auto; margin-left: auto; outline: 0px; border-color: #4499e7;\">\n<section style=\"margin-right: auto; margin-left: auto; outline: 0px; border-color: #4499e7;\">\n<blockquote style=\"margin: 5px auto; padding-top: 0px; padding-left: 0px; outline: 0px; color: var(--weui-fg-1); border: 0px none #4499e7;\">\n<section style=\"margin-right: auto; margin-left: auto; outline: 0px; text-align: center; border-color: #4499e7;\">\n<section style=\"margin-right: auto; margin-bottom: -38px; margin-left: auto; padding-right: 15px; padding-left: 15px; outline: 0px; display: inline-block; background-color: #4499e7; border-color: #4499e7;\">\n<p style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; color: #4499e7; border-color: #4499e7;\"><span style=\"outline: 0px; font-family: Arial, Helvetica, sans-serif;\"><strong style=\"outline: 0px;\"><span style=\"outline: 0px; border-color: #4499e7; color: #ffffff; font-size: 16px;\">\u7ed3\u6784\u578b\u6a21\u5f0f<\/span><\/strong><\/span><\/p>\n<\/section>\n<section style=\"margin: -40px 25px 50px; outline: 0px; border-color: #4499e7;\">\n<section style=\"margin-top: 3px; padding-top: 10px; padding-bottom: 10px; outline: 0px; display: inline-block; width: 495px; color: #4499e7; float: left; border-color: #4499e7;\">\n<section style=\"margin-top: 1em; outline: 0px; clear: both; border: 0px none #4499e7;\">\n<section style=\"margin-bottom: -3px; outline: 0px; float: right; border-color: #4499e7; width: 6px; border-radius: 50%; background-color: #4499e7; height: 6px !important;\"><\/section>\n<section style=\"margin-bottom: -2px; outline: 0px; text-align: left; border-color: #4499e7; width: 6px; border-radius: 50%; background-color: #4499e7; height: 6px !important;\"><\/section>\n<section style=\"margin-top: -20px; outline: 0px; text-decoration: inherit; border-color: #4499e7;\">\n<section style=\"outline: 0px; border-top: 1px solid #4499e7; width: 495px; float: left; border-right-color: #4499e7; border-bottom-color: #4499e7; border-left-color: #4499e7;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/blockquote>\n<\/section>\n<\/section>\n<\/blockquote>\n<\/section>\n<p style=\"outline: 0px;\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u524d\u9762\u521b\u5efa\u578b\u6a21\u5f0f\u4ecb\u7ecd\u4e86\u521b\u5efa\u5bf9\u8c61\u7684\u4e00\u4e9b\u8bbe\u8ba1\u6a21\u5f0f\uff0c\u8fd9\u8282\u4ecb\u7ecd\u7684\u7ed3\u6784\u578b\u6a21\u5f0f\u65e8\u5728\u901a\u8fc7\u6539\u53d8\u4ee3\u7801\u7ed3\u6784\u6765\u8fbe\u5230\u89e3\u8026\u7684\u76ee\u7684\uff0c\u4f7f\u5f97\u6211\u4eec\u7684\u4ee3\u7801\u5bb9\u6613\u7ef4\u62a4\u548c\u6269\u5c55\u3002<\/p>\n<h3 style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><\/h3>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px; border: 0px none initial;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; display: inline-block;\">\n<section style=\"padding-right: 10px; padding-left: 10px; outline: 0px; font-size: 16px; color: #494949;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u4ee3\u7406\u6a21\u5f0f<\/span><\/p>\n<\/section>\n<section style=\"margin-top: -10px; outline: 0px; background-color: #fcb42b; height: 8px; color: #ffffff;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">\u7b2c\u4e00\u4e2a\u8981\u4ecb\u7ecd\u7684\u4ee3\u7406\u6a21\u5f0f\u662f\u6700\u5e38\u4f7f\u7528\u7684\u6a21\u5f0f\u4e4b\u4e00\u4e86\uff0c\u7528\u4e00\u4e2a\u4ee3\u7406\u6765\u9690\u85cf\u5177\u4f53\u5b9e\u73b0\u7c7b\u7684\u5b9e\u73b0\u7ec6\u8282\uff0c\u901a\u5e38\u8fd8\u7528\u4e8e\u5728\u771f\u5b9e\u7684\u5b9e\u73b0\u7684\u524d\u540e\u6dfb\u52a0\u4e00\u90e8\u5206\u903b\u8f91\u3002<\/span><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u65e2\u7136\u8bf4\u662f<strong style=\"outline: 0px;\">\u4ee3\u7406<\/strong>\u00a0\uff0c\u90a3\u5c31\u8981\u5bf9\u5ba2\u6237\u7aef\u9690\u85cf\u771f\u5b9e\u5b9e\u73b0\uff0c\u7531\u4ee3\u7406\u6765\u8d1f\u8d23\u5ba2\u6237\u7aef\u7684\u6240\u6709\u8bf7\u6c42\u3002\u5f53\u7136\uff0c\u4ee3\u7406\u53ea\u662f\u4e2a\u4ee3\u7406\uff0c\u5b83\u4e0d\u4f1a\u5b8c\u6210\u5b9e\u9645\u7684\u4e1a\u52a1\u903b\u8f91\uff0c\u800c\u662f\u4e00\u5c42\u76ae\u800c\u5df2\uff0c\u4f46\u662f\u5bf9\u4e8e\u5ba2\u6237\u7aef\u6765\u8bf4\uff0c\u5b83\u5fc5\u987b\u8868\u73b0\u5f97\u5c31\u662f\u5ba2\u6237\u7aef\u9700\u8981\u7684\u771f\u5b9e\u5b9e\u73b0\u3002<\/p>\n<blockquote style=\"margin-top: 20px; margin-bottom: 20px; padding: 10px 10px 10px 20px; outline: 0px; border-left-color: rgba(0, 0, 0, 0.65); color: #6a737d; font-size: 0.9em; border-top: none; border-bottom: none; overflow: auto; border-right: 1px solid rgba(0, 0, 0, 0.65); background: #f9f9f9;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; font-size: 14px; color: black; line-height: 26px;\">\u7406\u89e3<strong style=\"outline: 0px;\">\u4ee3\u7406<\/strong>\u00a0\u8fd9\u4e2a\u8bcd\uff0c\u8fd9\u4e2a\u6a21\u5f0f\u5176\u5b9e\u5c31\u7b80\u5355\u4e86\u3002<\/p>\n<\/blockquote>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">interface<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">FoodService<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\">Food\u00a0<span style=\"outline: 0px; line-height: 26px;\">makeChicken<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span><\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\">Food\u00a0<span style=\"outline: 0px; line-height: 26px;\">makeNoodle<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span><\/span>;<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">FoodServiceImpl<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">implements<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">FoodService<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0Food\u00a0<span style=\"outline: 0px; line-height: 26px;\">makeChicken<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Food\u00a0f\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Chicken()<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0f.setChicken(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"1kg\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0f.setSpicy(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"1g\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0f.setSalt(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"3g\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0f;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0Food\u00a0<span style=\"outline: 0px; line-height: 26px;\">makeNoodle<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Food\u00a0f\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Noodle();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0f.setNoodle(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"500g\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0f.setSalt(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"5g\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0f;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u4ee3\u7406\u8981\u8868\u73b0\u5f97\u201c\u5c31\u50cf\u662f\u201d\u771f\u5b9e\u5b9e\u73b0\u7c7b\uff0c\u6240\u4ee5\u9700\u8981\u5b9e\u73b0\u00a0FoodService<\/span><br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">FoodServiceProxy<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">implements<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">FoodService<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5185\u90e8\u4e00\u5b9a\u8981\u6709\u4e00\u4e2a\u771f\u5b9e\u7684\u5b9e\u73b0\u7c7b\uff0c\u5f53\u7136\u4e5f\u53ef\u4ee5\u901a\u8fc7\u6784\u9020\u65b9\u6cd5\u6ce8\u5165<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0FoodService\u00a0foodService\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0FoodServiceImpl();<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0Food\u00a0<span style=\"outline: 0px; line-height: 26px;\">makeChicken<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u6211\u4eec\u9a6c\u4e0a\u8981\u5f00\u59cb\u5236\u4f5c\u9e21\u8089\u4e86\"<\/span>);<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5982\u679c\u6211\u4eec\u5b9a\u4e49\u8fd9\u53e5\u4e3a\u6838\u5fc3\u4ee3\u7801\u7684\u8bdd\uff0c\u90a3\u4e48\uff0c\u6838\u5fc3\u4ee3\u7801\u662f\u771f\u5b9e\u5b9e\u73b0\u7c7b\u505a\u7684\uff0c<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u4ee3\u7406\u53ea\u662f\u5728\u6838\u5fc3\u4ee3\u7801\u524d\u540e\u505a\u4e9b\u201c\u65e0\u8db3\u8f7b\u91cd\u201d\u7684\u4e8b\u60c5<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Food\u00a0food\u00a0=\u00a0foodService.makeChicken();<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u9e21\u8089\u5236\u4f5c\u5b8c\u6210\u5566\uff0c\u52a0\u70b9\u80e1\u6912\u7c89\"<\/span>);\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u589e\u5f3a<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0food.addCondiment(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"pepper\"<\/span>);<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0food;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0Food\u00a0<span style=\"outline: 0px; line-height: 26px;\">makeNoodle<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u51c6\u5907\u5236\u4f5c\u62c9\u9762~\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Food\u00a0food\u00a0=\u00a0foodService.makeNoodle();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u5236\u4f5c\u5b8c\u6210\u5566\"<\/span>)<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0food;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5ba2\u6237\u7aef\u8c03\u7528\uff0c\u6ce8\u610f\uff0c\u6211\u4eec\u8981\u7528\u4ee3\u7406\u6765\u5b9e\u4f8b\u5316\u63a5\u53e3\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u8fd9\u91cc\u7528\u4ee3\u7406\u7c7b\u6765\u5b9e\u4f8b\u5316<\/span><br style=\"outline: 0px;\" \/>FoodService\u00a0foodService\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0FoodServiceProxy();<br style=\"outline: 0px;\" \/>foodService.makeChicken();<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; outline: 0px; display: flex; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><figcaption style=\"margin-top: 5px; outline: 0px; text-align: center; color: #888888; font-size: 12px;\"><\/figcaption><\/figure>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005403768.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-ratio=\"0.5055555555555555\" data-type=\"png\" data-w=\"1080\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005403768.png\" data-ratio=\"0.5055555555555555\" data-type=\"png\" data-w=\"1080\" \/><\/noscript><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6211\u4eec\u53d1\u73b0\u6ca1\u6709\uff0c\u4ee3\u7406\u6a21\u5f0f\u8bf4\u767d\u4e86\u5c31\u662f\u505a\u00a0<strong style=\"outline: 0px;\">\u201c\u65b9\u6cd5\u5305\u88c5\u201d<\/strong>\u00a0\u6216\u505a\u00a0<strong style=\"outline: 0px;\">\u201c\u65b9\u6cd5\u589e\u5f3a\u201d<\/strong>\u00a0\u3002\u5728\u9762\u5411\u5207\u9762\u7f16\u7a0b\u4e2d\uff0c\u5176\u5b9e\u5c31\u662f\u52a8\u6001\u4ee3\u7406\u7684\u8fc7\u7a0b\u3002\u6bd4\u5982 Spring \u4e2d\uff0c\u6211\u4eec\u81ea\u5df1\u4e0d\u5b9a\u4e49\u4ee3\u7406\u7c7b\uff0c\u4f46\u662f Spring \u4f1a\u5e2e\u6211\u4eec\u52a8\u6001\u6765\u5b9a\u4e49\u4ee3\u7406\uff0c\u7136\u540e\u628a\u6211\u4eec\u5b9a\u4e49\u5728 @Before\u3001@After\u3001@Around \u4e2d\u7684\u4ee3\u7801\u903b\u8f91\u52a8\u6001\u6dfb\u52a0\u5230\u4ee3\u7406\u4e2d\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8bf4\u5230\u52a8\u6001\u4ee3\u7406\uff0c\u53c8\u53ef\u4ee5\u5c55\u5f00\u8bf4\uff0cSpring \u4e2d\u5b9e\u73b0\u52a8\u6001\u4ee3\u7406\u6709\u4e24\u79cd\uff0c\u4e00\u79cd\u662f\u5982\u679c\u6211\u4eec\u7684\u7c7b\u5b9a\u4e49\u4e86\u63a5\u53e3\uff0c\u5982 UserService \u63a5\u53e3\u548c UserServiceImpl \u5b9e\u73b0\uff0c\u90a3\u4e48\u91c7\u7528 JDK \u7684\u52a8\u6001\u4ee3\u7406\uff0c\u611f\u5174\u8da3\u7684\u8bfb\u8005\u53ef\u4ee5\u53bb\u770b\u770b java.lang.reflect.Proxy \u7c7b\u7684\u6e90\u7801\uff1b\u53e6\u4e00\u79cd\u662f\u6211\u4eec\u81ea\u5df1\u6ca1\u6709\u5b9a\u4e49\u63a5\u53e3\u7684\uff0cSpring \u4f1a\u91c7\u7528 CGLIB \u8fdb\u884c\u52a8\u6001\u4ee3\u7406\uff0c\u5b83\u662f\u4e00\u4e2a jar \u5305\uff0c\u6027\u80fd\u8fd8\u4e0d\u9519\u3002<\/p>\n<h3 style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><\/h3>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px; border: 0px none initial;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; display: inline-block;\">\n<section style=\"padding-right: 10px; padding-left: 10px; outline: 0px; font-size: 16px; color: #494949;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u9002\u914d\u5668\u6a21\u5f0f<\/span><\/p>\n<\/section>\n<section style=\"margin-top: -10px; outline: 0px; background-color: #fcb42b; height: 8px; color: #ffffff;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">\u8bf4\u5b8c\u4ee3\u7406\u6a21\u5f0f\uff0c\u8bf4\u9002\u914d\u5668\u6a21\u5f0f\uff0c\u662f\u56e0\u4e3a\u5b83\u4eec\u5f88\u76f8\u4f3c\uff0c\u8fd9\u91cc\u53ef\u4ee5\u505a\u4e2a\u6bd4\u8f83\u3002<\/span><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u9002\u914d\u5668\u6a21\u5f0f\u505a\u7684\u5c31\u662f\uff0c\u6709\u4e00\u4e2a\u63a5\u53e3\u9700\u8981\u5b9e\u73b0\uff0c\u4f46\u662f\u6211\u4eec\u73b0\u6210\u7684\u5bf9\u8c61\u90fd\u4e0d\u6ee1\u8db3\uff0c\u9700\u8981\u52a0\u4e00\u5c42\u9002\u914d\u5668\u6765\u8fdb\u884c\u9002\u914d\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u9002\u914d\u5668\u6a21\u5f0f\u603b\u4f53\u6765\u8bf4\u5206\u4e09\u79cd\uff1a\u9ed8\u8ba4\u9002\u914d\u5668\u6a21\u5f0f\u3001\u5bf9\u8c61\u9002\u914d\u5668\u6a21\u5f0f\u3001\u7c7b\u9002\u914d\u5668\u6a21\u5f0f\u3002\u5148\u4e0d\u6025\u7740\u5206\u6e05\u695a\u8fd9\u51e0\u4e2a\uff0c\u5148\u770b\u770b\u4f8b\u5b50\u518d\u8bf4\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 15px;\"><strong style=\"outline: 0px;\">\uff081\uff09\u9ed8\u8ba4\u9002\u914d\u5668\u6a21\u5f0f<\/strong><\/span><\/p>\n<\/section>\n<section style=\"outline: 0px;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">\u9996\u5148\uff0c\u6211\u4eec\u5148\u770b\u770b\u6700\u7b80\u5355\u7684\u9002\u914d\u5668\u6a21\u5f0f<\/span><strong style=\"outline: 0px; letter-spacing: 0px;\">\u9ed8\u8ba4\u9002\u914d\u5668\u6a21\u5f0f(Default Adapter)<\/strong><span style=\"outline: 0px; letter-spacing: 0px;\">\u00a0\u662f\u600e\u4e48\u6837\u7684\u3002<\/span><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6211\u4eec\u7528 Appache commons-io \u5305\u4e2d\u7684 FileAlterationListener \u505a\u4f8b\u5b50\uff0c\u6b64\u63a5\u53e3\u5b9a\u4e49\u4e86\u5f88\u591a\u7684\u65b9\u6cd5\uff0c\u7528\u4e8e\u5bf9\u6587\u4ef6\u6216\u6587\u4ef6\u5939\u8fdb\u884c\u76d1\u63a7\uff0c\u4e00\u65e6\u53d1\u751f\u4e86\u5bf9\u5e94\u7684\u64cd\u4f5c\uff0c\u5c31\u4f1a\u89e6\u53d1\u76f8\u5e94\u7684\u65b9\u6cd5\u3002<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">interface<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">FileAlterationListener<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">onStart<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">final<\/span>\u00a0FileAlterationObserver\u00a0observer)<\/span><\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">onDirectoryCreate<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">final<\/span>\u00a0File\u00a0directory)<\/span><\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">onDirectoryChange<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">final<\/span>\u00a0File\u00a0directory)<\/span><\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">onDirectoryDelete<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">final<\/span>\u00a0File\u00a0directory)<\/span><\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">onFileCreate<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">final<\/span>\u00a0File\u00a0file)<\/span><\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">onFileChange<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">final<\/span>\u00a0File\u00a0file)<\/span><\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">onFileDelete<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">final<\/span>\u00a0File\u00a0file)<\/span><\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">onStop<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">final<\/span>\u00a0FileAlterationObserver\u00a0observer)<\/span><\/span>;<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6b64\u63a5\u53e3\u7684\u4e00\u5927\u95ee\u9898\u662f\u62bd\u8c61\u65b9\u6cd5\u592a\u591a\u4e86\uff0c\u5982\u679c\u6211\u4eec\u8981\u7528\u8fd9\u4e2a\u63a5\u53e3\uff0c\u610f\u5473\u7740\u6211\u4eec\u8981\u5b9e\u73b0\u6bcf\u4e00\u4e2a\u62bd\u8c61\u65b9\u6cd5\uff0c\u5982\u679c\u6211\u4eec\u53ea\u662f\u60f3\u8981\u76d1\u63a7\u6587\u4ef6\u5939\u4e2d\u7684<strong style=\"outline: 0px;\">\u6587\u4ef6\u521b\u5efa<\/strong>\u00a0\u548c<strong style=\"outline: 0px;\">\u6587\u4ef6\u5220\u9664<\/strong>\u00a0\u4e8b\u4ef6\uff0c\u53ef\u662f\u6211\u4eec\u8fd8\u662f\u4e0d\u5f97\u4e0d\u5b9e\u73b0\u6240\u6709\u7684\u65b9\u6cd5\uff0c\u5f88\u660e\u663e\uff0c\u8fd9\u4e0d\u662f\u6211\u4eec\u60f3\u8981\u7684\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6240\u4ee5\uff0c\u6211\u4eec\u9700\u8981\u4e0b\u9762\u7684\u4e00\u4e2a<strong style=\"outline: 0px;\">\u9002\u914d\u5668<\/strong>\u00a0\uff0c\u5b83\u7528\u4e8e\u5b9e\u73b0\u4e0a\u9762\u7684\u63a5\u53e3\uff0c\u4f46\u662f<strong style=\"outline: 0px;\">\u6240\u6709\u7684\u65b9\u6cd5\u90fd\u662f\u7a7a\u65b9\u6cd5<\/strong>\u00a0\uff0c\u8fd9\u6837\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u8f6c\u800c\u5b9a\u4e49\u81ea\u5df1\u7684\u7c7b\u6765\u7ee7\u627f\u4e0b\u9762\u8fd9\u4e2a\u7c7b\u5373\u53ef\u3002<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">FileAlterationListenerAdaptor<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">implements<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">FileAlterationListener<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">onStart<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">final<\/span>\u00a0FileAlterationObserver\u00a0observer)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">onDirectoryCreate<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">final<\/span>\u00a0File\u00a0directory)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">onDirectoryChange<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">final<\/span>\u00a0File\u00a0directory)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">onDirectoryDelete<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">final<\/span>\u00a0File\u00a0directory)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">onFileCreate<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">final<\/span>\u00a0File\u00a0file)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">onFileChange<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">final<\/span>\u00a0File\u00a0file)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">onFileDelete<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">final<\/span>\u00a0File\u00a0file)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">onStop<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">final<\/span>\u00a0FileAlterationObserver\u00a0observer)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6bd4\u5982\u6211\u4eec\u53ef\u4ee5\u5b9a\u4e49\u4ee5\u4e0b\u7c7b\uff0c\u6211\u4eec\u4ec5\u4ec5\u9700\u8981\u5b9e\u73b0\u6211\u4eec\u60f3\u5b9e\u73b0\u7684\u65b9\u6cd5\u5c31\u53ef\u4ee5\u4e86\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">FileMonitor<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">extends<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">FileAlterationListenerAdaptor<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">onFileCreate<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">final<\/span>\u00a0File\u00a0file)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u6587\u4ef6\u521b\u5efa<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0doSomething();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">onFileDelete<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">final<\/span>\u00a0File\u00a0file)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u6587\u4ef6\u5220\u9664<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0doSomething();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5f53\u7136\uff0c\u4e0a\u9762\u8bf4\u7684\u53ea\u662f\u9002\u914d\u5668\u6a21\u5f0f\u7684\u5176\u4e2d\u4e00\u79cd\uff0c\u4e5f\u662f\u6700\u7b80\u5355\u7684\u4e00\u79cd\uff0c\u65e0\u9700\u591a\u8a00\u3002\u4e0b\u9762\uff0c\u518d\u4ecb\u7ecd\u201c\u6b63\u7edf\u7684\u201d\u9002\u914d\u5668\u6a21\u5f0f\u3002<\/p>\n<h4 style=\"margin-top: 30px; margin-bottom: 15px; outline: 0px; font-weight: bold; font-size: 18px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 15px;\">\uff082\uff09\u5bf9\u8c61\u9002\u914d\u5668\u6a21\u5f0f<\/span><\/strong><\/h4>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6765\u770b\u4e00\u4e2a\u300aHead First \u8bbe\u8ba1\u6a21\u5f0f\u300b\u4e2d\u7684\u4e00\u4e2a\u4f8b\u5b50\uff0c\u6211\u7a0d\u5fae\u4fee\u6539\u4e86\u4e00\u4e0b\uff0c\u770b\u770b\u600e\u4e48\u5c06\u9e21\u9002\u914d\u6210\u9e2d\uff0c\u8fd9\u6837\u9e21\u4e5f\u80fd\u5f53\u9e2d\u6765\u7528\u3002\u56e0\u4e3a\uff0c\u73b0\u5728\u9e2d\u8fd9\u4e2a\u63a5\u53e3\uff0c\u6211\u4eec\u6ca1\u6709\u5408\u9002\u7684\u5b9e\u73b0\u7c7b\u53ef\u4ee5\u7528\uff0c\u6240\u4ee5\u9700\u8981\u9002\u914d\u5668\u3002<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">interface<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Duck<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">quack<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span><\/span>;\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u9e2d\u7684\u5471\u5471\u53eb<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">fly<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span><\/span>;\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u98de<\/span><br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">interface<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Cock<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">gobble<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span><\/span>;\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u9e21\u7684\u5495\u5495\u53eb<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">fly<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span><\/span>;\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u98de<\/span><br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">WildCock<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">implements<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Cock<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">gobble<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u5495\u5495\u53eb\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">fly<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u9e21\u4e5f\u4f1a\u98de\u54e6\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u9e2d\u63a5\u53e3\u6709 fly() \u548c quare() \u4e24\u4e2a\u65b9\u6cd5\uff0c\u9e21 Cock \u5982\u679c\u8981\u5192\u5145\u9e2d\uff0cfly() \u65b9\u6cd5\u662f\u73b0\u6210\u7684\uff0c\u4f46\u662f\u9e21\u4e0d\u4f1a\u9e2d\u7684\u5471\u5471\u53eb\uff0c\u6ca1\u6709 quack() \u65b9\u6cd5\u3002\u8fd9\u4e2a\u65f6\u5019\u5c31\u9700\u8981\u9002\u914d\u4e86\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u6beb\u65e0\u7591\u95ee\uff0c\u9996\u5148\uff0c\u8fd9\u4e2a\u9002\u914d\u5668\u80af\u5b9a\u9700\u8981\u00a0implements\u00a0Duck\uff0c\u8fd9\u6837\u624d\u80fd\u5f53\u505a\u9e2d\u6765\u7528<\/span><br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">CockAdapter<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">implements<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Duck<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0Cock\u00a0cock;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u6784\u9020\u65b9\u6cd5\u4e2d\u9700\u8981\u4e00\u4e2a\u9e21\u7684\u5b9e\u4f8b\uff0c\u6b64\u7c7b\u5c31\u662f\u5c06\u8fd9\u53ea\u9e21\u9002\u914d\u6210\u9e2d\u6765\u7528<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">CockAdapter<\/span><span style=\"outline: 0px; line-height: 26px;\">(Cock\u00a0cock)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.cock\u00a0=\u00a0cock;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5b9e\u73b0\u9e2d\u7684\u5471\u5471\u53eb\u65b9\u6cd5<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #9b9b9b; line-height: 26px;\">@Override<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">quack<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5185\u90e8\u5176\u5b9e\u662f\u4e00\u53ea\u9e21\u7684\u5495\u5495\u53eb<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0cock.gobble();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #9b9b9b; line-height: 26px;\">@Override<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">fly<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0cock.fly();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5ba2\u6237\u7aef\u8c03\u7528\u5f88\u7b80\u5355\u4e86\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">main<\/span><span style=\"outline: 0px; line-height: 26px;\">(String[]\u00a0args)<\/span>\u00a0<\/span>{\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u6709\u4e00\u53ea\u91ce\u9e21\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Cock\u00a0wildCock\u00a0=\u00a0new\u00a0WildCock();\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/\u00a0\u6210\u529f\u5c06\u91ce\u9e21\u9002\u914d\u6210\u9e2d\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Duck\u00a0duck\u00a0=\u00a0new\u00a0CockAdapter(wildCock);\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0...}<\/span><br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5230\u8fd9\u91cc\uff0c\u5927\u5bb6\u4e5f\u5c31\u77e5\u9053\u4e86\u9002\u914d\u5668\u6a21\u5f0f\u662f\u600e\u4e48\u56de\u4e8b\u4e86\u3002\u65e0\u975e\u662f\u6211\u4eec\u9700\u8981\u4e00\u53ea\u9e2d\uff0c\u4f46\u662f\u6211\u4eec\u53ea\u6709\u4e00\u53ea\u9e21\uff0c\u8fd9\u4e2a\u65f6\u5019\u5c31\u9700\u8981\u5b9a\u4e49\u4e00\u4e2a\u9002\u914d\u5668\uff0c\u7531\u8fd9\u4e2a\u9002\u914d\u5668\u6765\u5145\u5f53\u9e2d\uff0c\u4f46\u662f\u9002\u914d\u5668\u91cc\u9762\u7684\u65b9\u6cd5\u8fd8\u662f\u7531\u9e21\u6765\u5b9e\u73b0\u7684\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6211\u4eec\u7528\u4e00\u4e2a\u56fe\u6765\u7b80\u5355\u8bf4\u660e\u4e0b\uff1a<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; outline: 0px; display: flex; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><figcaption style=\"margin-top: 5px; outline: 0px; text-align: center; color: #888888; font-size: 12px;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005406171.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-ratio=\"0.5962962962962963\" data-type=\"png\" data-w=\"1080\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005406171.png\" data-ratio=\"0.5962962962962963\" data-type=\"png\" data-w=\"1080\" \/><\/noscript><\/figcaption><\/figure>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u4e0a\u56fe\u5e94\u8be5\u8fd8\u662f\u5f88\u5bb9\u6613\u7406\u89e3\u7684\uff0c\u6211\u5c31\u4e0d\u505a\u66f4\u591a\u7684\u89e3\u91ca\u4e86\u3002\u4e0b\u9762\uff0c\u6211\u4eec\u770b\u770b\u7c7b\u9002\u914d\u6a21\u5f0f\u600e\u4e48\u6837\u7684\u3002<\/p>\n<h4 style=\"margin-top: 30px; margin-bottom: 15px; outline: 0px; font-weight: bold; font-size: 18px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 15px;\">\uff083\uff09\u7c7b\u9002\u914d\u5668\u6a21\u5f0f<\/span><\/strong><\/h4>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5e9f\u8bdd\u5c11\u8bf4\uff0c\u76f4\u63a5\u4e0a\u56fe\uff1a<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; outline: 0px; display: flex; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><figcaption style=\"margin-top: 5px; outline: 0px; text-align: center; color: #888888; font-size: 12px;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005410415.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-ratio=\"0.5638888888888889\" data-type=\"png\" data-w=\"1080\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005410415.png\" data-ratio=\"0.5638888888888889\" data-type=\"png\" data-w=\"1080\" \/><\/noscript><\/figcaption><\/figure>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u770b\u5230\u8fd9\u4e2a\u56fe\uff0c\u5927\u5bb6\u5e94\u8be5\u5f88\u5bb9\u6613\u7406\u89e3\u7684\u5427\uff0c\u901a\u8fc7\u7ee7\u627f\u7684\u65b9\u6cd5\uff0c\u9002\u914d\u5668\u81ea\u52a8\u83b7\u5f97\u4e86\u6240\u9700\u8981\u7684\u5927\u90e8\u5206\u65b9\u6cd5\u3002\u8fd9\u4e2a\u65f6\u5019\uff0c\u5ba2\u6237\u7aef\u4f7f\u7528\u66f4\u52a0\u7b80\u5355\uff0c\u76f4\u63a5\u00a0<code style=\"margin-right: 2px; margin-left: 2px; padding: 2px 4px; outline: 0px; border-radius: 4px; background-color: rgba(27, 31, 35, 0.05); font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #ff6441;\">Target t = new SomeAdapter();<\/code>\u00a0\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<h4 style=\"margin-top: 30px; margin-bottom: 15px; outline: 0px; font-weight: bold; font-size: 18px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 15px;\">\uff084\uff09\u9002\u914d\u5668\u6a21\u5f0f\u603b\u7ed3<\/span><\/strong><\/h4>\n<ol class=\"list-paddingleft-1\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px; outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px; color: black;\">\u7c7b\u9002\u914d\u548c\u5bf9\u8c61\u9002\u914d\u7684\u5f02\u540c<\/p>\n<blockquote style=\"margin-top: 20px; margin-bottom: 20px; padding: 10px 10px 10px 20px; outline: 0px; border-left-color: rgba(0, 0, 0, 0.65); color: #6a737d; font-size: 0.9em; border-top: none; border-bottom: none; overflow: auto; border-right: 1px solid rgba(0, 0, 0, 0.65); background: #f9f9f9;\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; font-size: 14px; color: black; line-height: 26px;\">\u4e00\u4e2a\u91c7\u7528\u7ee7\u627f\uff0c\u4e00\u4e2a\u91c7\u7528\u7ec4\u5408\uff1b<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; font-size: 14px; color: black; line-height: 26px;\">\u7c7b\u9002\u914d\u5c5e\u4e8e\u9759\u6001\u5b9e\u73b0\uff0c\u5bf9\u8c61\u9002\u914d\u5c5e\u4e8e\u7ec4\u5408\u7684\u52a8\u6001\u5b9e\u73b0\uff0c\u5bf9\u8c61\u9002\u914d\u9700\u8981\u591a\u5b9e\u4f8b\u5316\u4e00\u4e2a\u5bf9\u8c61\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; font-size: 14px; color: black; line-height: 26px;\">\u603b\u4f53\u6765\u8bf4\uff0c\u5bf9\u8c61\u9002\u914d\u7528\u5f97\u6bd4\u8f83\u591a\u3002<\/p>\n<\/blockquote>\n<\/section>\n<\/li>\n<li style=\"outline: 0px;\">\n<section style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; line-height: 26px; color: #010101;\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px; color: black;\">\u9002\u914d\u5668\u6a21\u5f0f\u548c\u4ee3\u7406\u6a21\u5f0f\u7684\u5f02\u540c<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px; color: black;\">\u6bd4\u8f83\u8fd9\u4e24\u79cd\u6a21\u5f0f\uff0c\u5176\u5b9e\u662f\u6bd4\u8f83\u5bf9\u8c61\u9002\u914d\u5668\u6a21\u5f0f\u548c\u4ee3\u7406\u6a21\u5f0f\uff0c\u5728\u4ee3\u7801\u7ed3\u6784\u4e0a\uff0c\u5b83\u4eec\u5f88\u76f8\u4f3c\uff0c\u90fd\u9700\u8981\u4e00\u4e2a\u5177\u4f53\u7684\u5b9e\u73b0\u7c7b\u7684\u5b9e\u4f8b\u3002\u4f46\u662f\u5b83\u4eec\u7684\u76ee\u7684\u4e0d\u4e00\u6837\uff0c\u4ee3\u7406\u6a21\u5f0f\u505a\u7684\u662f\u589e\u5f3a\u539f\u65b9\u6cd5\u7684\u6d3b\uff1b\u9002\u914d\u5668\u505a\u7684\u662f\u9002\u914d\u7684\u6d3b\uff0c\u4e3a\u7684\u662f\u63d0\u4f9b\u201c\u628a\u9e21\u5305\u88c5\u6210\u9e2d\uff0c\u7136\u540e\u5f53\u505a\u9e2d\u6765\u4f7f\u7528\u201d\uff0c\u800c\u9e21\u548c\u9e2d\u5b83\u4eec\u4e4b\u95f4\u539f\u672c\u6ca1\u6709\u7ee7\u627f\u5173\u7cfb\u3002<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; outline: 0px; display: flex; flex-direction: column; justify-content: center; align-items: center;\"><figcaption style=\"margin-top: 5px; outline: 0px; text-align: center; color: #888888; font-size: 12px;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005413805.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-ratio=\"0.7805555555555556\" data-type=\"png\" data-w=\"1080\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005413805.png\" data-ratio=\"0.7805555555555556\" data-type=\"png\" data-w=\"1080\" \/><\/noscript><\/figcaption><\/figure>\n<\/section>\n<\/li>\n<\/ol>\n<h3 style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><\/h3>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px; border: 0px none initial;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; display: inline-block;\">\n<section style=\"padding-right: 10px; padding-left: 10px; outline: 0px; font-size: 16px; color: #494949;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u6865\u6881\u6a21\u5f0f<\/span><\/p>\n<\/section>\n<section style=\"margin-top: -10px; outline: 0px; background-color: #fcb42b; height: 8px; color: #ffffff;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">\u7406\u89e3\u6865\u6881\u6a21\u5f0f\uff0c\u5176\u5b9e\u5c31\u662f\u7406\u89e3\u4ee3\u7801\u62bd\u8c61\u548c\u89e3\u8026\u3002<\/span><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6211\u4eec\u9996\u5148\u9700\u8981\u4e00\u4e2a\u6865\u6881\uff0c\u5b83\u662f\u4e00\u4e2a\u63a5\u53e3\uff0c\u5b9a\u4e49\u63d0\u4f9b\u7684\u63a5\u53e3\u65b9\u6cd5\u3002<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">interface<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">DrawAPI<\/span>\u00a0<\/span>{\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">draw<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0radius,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0x,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0y)<\/span><\/span>;}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u7136\u540e\u662f\u4e00\u7cfb\u5217\u5b9e\u73b0\u7c7b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">RedPen<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">implements<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">DrawAPI<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #9b9b9b; line-height: 26px;\">@Override<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">draw<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0radius,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0x,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0y)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u7528\u7ea2\u8272\u7b14\u753b\u56fe\uff0cradius:\"<\/span>\u00a0+\u00a0radius\u00a0+\u00a0<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\",\u00a0x:\"<\/span>\u00a0+\u00a0x\u00a0+\u00a0<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\",\u00a0y:\"<\/span>\u00a0+\u00a0y);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">GreenPen<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">implements<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">DrawAPI<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #9b9b9b; line-height: 26px;\">@Override<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">draw<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0radius,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0x,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0y)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u7528\u7eff\u8272\u7b14\u753b\u56fe\uff0cradius:\"<\/span>\u00a0+\u00a0radius\u00a0+\u00a0<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\",\u00a0x:\"<\/span>\u00a0+\u00a0x\u00a0+\u00a0<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\",\u00a0y:\"<\/span>\u00a0+\u00a0y);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">BluePen<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">implements<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">DrawAPI<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #9b9b9b; line-height: 26px;\">@Override<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">draw<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0radius,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0x,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0y)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u7528\u84dd\u8272\u7b14\u753b\u56fe\uff0cradius:\"<\/span>\u00a0+\u00a0radius\u00a0+\u00a0<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\",\u00a0x:\"<\/span>\u00a0+\u00a0x\u00a0+\u00a0<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\",\u00a0y:\"<\/span>\u00a0+\u00a0y);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5b9a\u4e49\u4e00\u4e2a\u62bd\u8c61\u7c7b\uff0c\u6b64\u7c7b\u7684\u5b9e\u73b0\u7c7b\u90fd\u9700\u8981\u4f7f\u7528 DrawAPI\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">abstract<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Shape<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">protected<\/span>\u00a0DrawAPI\u00a0drawAPI;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">protected<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">Shape<\/span><span style=\"outline: 0px; line-height: 26px;\">(DrawAPI\u00a0drawAPI)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.drawAPI\u00a0=\u00a0drawAPI;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">abstract<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">draw<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span><\/span>;<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5b9a\u4e49\u62bd\u8c61\u7c7b\u7684\u5b50\u7c7b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5706\u5f62<\/span><br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Circle<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">extends<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Shape<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0radius;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">Circle<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0radius,\u00a0DrawAPI\u00a0drawAPI)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">super<\/span>(drawAPI);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.radius\u00a0=\u00a0radius;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">draw<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0drawAPI.draw(radius,\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\">0<\/span>,\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\">0<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u957f\u65b9\u5f62<\/span><br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Rectangle<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">extends<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Shape<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0x;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0y;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">Rectangle<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0x,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0y,\u00a0DrawAPI\u00a0drawAPI)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">super<\/span>(drawAPI);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.x\u00a0=\u00a0x;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.y\u00a0=\u00a0y;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">draw<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0drawAPI.draw(<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\">0<\/span>,\u00a0x,\u00a0y);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6700\u540e\uff0c\u6211\u4eec\u6765\u770b\u5ba2\u6237\u7aef\u6f14\u793a\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">main<\/span><span style=\"outline: 0px; line-height: 26px;\">(String[]\u00a0args)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0Shape\u00a0greenCircle\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Circle(<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\">10<\/span>,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0GreenPen());<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0Shape\u00a0redRectangle\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Rectangle(<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\">4<\/span>,\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\">8<\/span>,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0RedPen());<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0greenCircle.draw();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0redRectangle.draw();<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u53ef\u80fd\u5927\u5bb6\u770b\u4e0a\u9762\u4e00\u6b65\u6b65\u8fd8\u4e0d\u662f\u7279\u522b\u6e05\u6670\uff0c\u6211\u628a\u6240\u6709\u7684\u4e1c\u897f\u6574\u5408\u5230\u4e00\u5f20\u56fe\u4e0a\uff1a<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; outline: 0px; display: flex; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><figcaption style=\"margin-top: 5px; outline: 0px; text-align: center; color: #888888; font-size: 12px;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005418303.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-ratio=\"0.75\" data-type=\"png\" data-w=\"1080\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005418303.png\" data-ratio=\"0.75\" data-type=\"png\" data-w=\"1080\" \/><\/noscript><\/figcaption><\/figure>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8fd9\u56de\u5927\u5bb6\u5e94\u8be5\u5c31\u77e5\u9053\u62bd\u8c61\u5728\u54ea\u91cc\uff0c\u600e\u4e48\u89e3\u8026\u4e86\u5427\u3002\u6865\u6881\u6a21\u5f0f\u7684\u4f18\u70b9\u4e5f\u662f\u663e\u800c\u6613\u89c1\u7684\uff0c\u5c31\u662f\u975e\u5e38\u5bb9\u6613\u8fdb\u884c\u6269\u5c55\u3002<\/p>\n<blockquote style=\"margin-top: 20px; margin-bottom: 20px; padding: 10px 10px 10px 20px; outline: 0px; border-left-color: rgba(0, 0, 0, 0.65); color: #6a737d; font-size: 0.9em; border-top: none; border-bottom: none; overflow: auto; border-right: 1px solid rgba(0, 0, 0, 0.65); background: #f9f9f9;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; font-size: 14px; color: black; line-height: 26px;\">\u672c\u8282\u5f15\u7528\u4e86\u8fd9\u91cc\u7684\u4f8b\u5b50\uff0c\u5e76\u5bf9\u5176\u8fdb\u884c\u4e86\u4fee\u6539\u3002<\/p>\n<\/blockquote>\n<h3 style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><\/h3>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px; border: 0px none initial;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; display: inline-block;\">\n<section style=\"padding-right: 10px; padding-left: 10px; outline: 0px; font-size: 16px; color: #494949;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u88c5\u9970\u6a21\u5f0f<\/span><\/p>\n<\/section>\n<section style=\"margin-top: -10px; outline: 0px; background-color: #fcb42b; height: 8px; color: #ffffff;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">\u8981\u628a\u88c5\u9970\u6a21\u5f0f\u8bf4\u6e05\u695a\u660e\u767d\uff0c\u4e0d\u662f\u4ef6\u5bb9\u6613\u7684\u4e8b\u60c5\u3002<\/span><span style=\"outline: 0px; letter-spacing: 0px;\">\u4e5f\u8bb8\u8bfb\u8005\u77e5\u9053\u00a0<\/span><strong style=\"outline: 0px; letter-spacing: 0px;\">Java IO<\/strong><span style=\"outline: 0px; letter-spacing: 0px;\">\u00a0\u4e2d\u7684\u51e0\u4e2a\u7c7b\u662f\u5178\u578b\u7684\u88c5\u9970\u6a21\u5f0f\u7684\u5e94\u7528\uff0c\u4f46\u662f\u8bfb\u8005\u4e0d\u4e00\u5b9a\u6e05\u695a\u5176\u4e2d\u7684\u5173\u7cfb\uff0c\u4e5f\u8bb8\u770b\u5b8c\u5c31\u5fd8\u4e86\uff0c\u5e0c\u671b\u770b\u5b8c\u8fd9\u8282\u540e\uff0c\u8bfb\u8005\u53ef\u4ee5\u5bf9\u5176\u6709\u66f4\u6df1\u7684\u611f\u609f\u3002<\/span><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u9996\u5148\uff0c\u6211\u4eec\u5148\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u56fe\uff0c\u770b\u8fd9\u4e2a\u56fe\u7684\u65f6\u5019\uff0c\u4e86\u89e3\u4e0b\u5c42\u6b21\u7ed3\u6784\u5c31\u53ef\u4ee5\u4e86\uff1a<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; outline: 0px; display: flex; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><figcaption style=\"margin-top: 5px; outline: 0px; text-align: center; color: #888888; font-size: 12px;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005423439.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-ratio=\"0.7222222222222222\" data-type=\"png\" data-w=\"1080\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005423439.png\" data-ratio=\"0.7222222222222222\" data-type=\"png\" data-w=\"1080\" \/><\/noscript><\/figcaption><\/figure>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6211\u4eec\u6765\u8bf4\u8bf4\u88c5\u9970\u6a21\u5f0f\u7684\u51fa\u53d1\u70b9\uff0c\u4ece\u56fe\u4e2d\u53ef\u4ee5\u770b\u5230\uff0c\u63a5\u53e3\u00a0<code style=\"margin-right: 2px; margin-left: 2px; padding: 2px 4px; outline: 0px; border-radius: 4px; background-color: rgba(27, 31, 35, 0.05); font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #ff6441;\">Component<\/code>\u00a0\u5176\u5b9e\u5df2\u7ecf\u6709\u4e86\u00a0<code style=\"margin-right: 2px; margin-left: 2px; padding: 2px 4px; outline: 0px; border-radius: 4px; background-color: rgba(27, 31, 35, 0.05); font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #ff6441;\">ConcreteComponentA<\/code>\u00a0\u548c\u00a0<code style=\"margin-right: 2px; margin-left: 2px; padding: 2px 4px; outline: 0px; border-radius: 4px; background-color: rgba(27, 31, 35, 0.05); font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #ff6441;\">ConcreteComponentB<\/code>\u00a0\u4e24\u4e2a\u5b9e\u73b0\u7c7b\u4e86\uff0c\u4f46\u662f\uff0c\u5982\u679c\u6211\u4eec\u8981<strong style=\"outline: 0px;\">\u589e\u5f3a<\/strong>\u00a0\u8fd9\u4e24\u4e2a\u5b9e\u73b0\u7c7b\u7684\u8bdd\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u91c7\u7528\u88c5\u9970\u6a21\u5f0f\uff0c\u7528\u5177\u4f53\u7684\u88c5\u9970\u5668\u6765<strong style=\"outline: 0px;\">\u88c5\u9970<\/strong>\u00a0\u5b9e\u73b0\u7c7b\uff0c\u4ee5\u8fbe\u5230\u589e\u5f3a\u7684\u76ee\u7684\u3002<\/p>\n<blockquote style=\"margin-top: 20px; margin-bottom: 20px; padding: 10px 10px 10px 20px; outline: 0px; border-left-color: rgba(0, 0, 0, 0.65); color: #6a737d; font-size: 0.9em; border-top: none; border-bottom: none; overflow: auto; border-right: 1px solid rgba(0, 0, 0, 0.65); background: #f9f9f9;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; font-size: 14px; color: black; line-height: 26px;\">\u4ece\u540d\u5b57\u6765\u7b80\u5355\u89e3\u91ca\u4e0b\u88c5\u9970\u5668\u3002\u65e2\u7136\u8bf4\u662f\u88c5\u9970\uff0c\u90a3\u4e48\u5f80\u5f80\u5c31\u662f<strong style=\"outline: 0px;\">\u6dfb\u52a0\u5c0f\u529f\u80fd<\/strong>\u00a0\u8fd9\u79cd\uff0c\u800c\u4e14\uff0c\u6211\u4eec\u8981\u6ee1\u8db3\u53ef\u4ee5\u6dfb\u52a0\u591a\u4e2a\u5c0f\u529f\u80fd\u3002\u6700\u7b80\u5355\u7684\uff0c\u4ee3\u7406\u6a21\u5f0f\u5c31\u53ef\u4ee5\u5b9e\u73b0\u529f\u80fd\u7684\u589e\u5f3a\uff0c\u4f46\u662f\u4ee3\u7406\u4e0d\u5bb9\u6613\u5b9e\u73b0\u591a\u4e2a\u529f\u80fd\u7684\u589e\u5f3a\uff0c\u5f53\u7136\u4f60\u53ef\u4ee5\u8bf4\u7528\u4ee3\u7406\u5305\u88c5\u4ee3\u7406\u7684\u591a\u5c42\u5305\u88c5\u65b9\u5f0f\uff0c\u4f46\u662f\u90a3\u6837\u7684\u8bdd\u4ee3\u7801\u5c31\u590d\u6742\u4e86\u3002<\/p>\n<\/blockquote>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u9996\u5148\u660e\u767d\u4e00\u4e9b\u7b80\u5355\u7684\u6982\u5ff5\uff0c\u4ece\u56fe\u4e2d\u6211\u4eec\u770b\u5230\uff0c\u6240\u6709\u7684\u5177\u4f53\u88c5\u9970\u8005\u4eec\u00a0<em style=\"outline: 0px;\"><em style=\"outline: 0px;\">ConcreteDecorator*<\/em>\u00a0* \u90fd\u53ef\u4ee5\u4f5c\u4e3a Component \u6765\u4f7f\u7528\uff0c\u56e0\u4e3a\u5b83\u4eec\u90fd\u5b9e\u73b0\u4e86 Component \u4e2d\u7684\u6240\u6709\u63a5\u53e3\u3002\u5b83\u4eec\u548c Component \u5b9e\u73b0\u7c7b ConcreteComponent<\/em>\u00a0\u7684\u533a\u522b\u662f\uff0c\u5b83\u4eec\u53ea\u662f\u88c5\u9970\u8005\uff0c\u8d77<strong style=\"outline: 0px;\">\u88c5\u9970<\/strong>\u00a0\u4f5c\u7528\uff0c\u4e5f\u5c31\u662f\u5373\u4f7f\u5b83\u4eec\u770b\u4e0a\u53bb\u725b\u903c\u8f70\u8f70\uff0c\u4f46\u662f\u5b83\u4eec\u90fd\u53ea\u662f\u5728\u5177\u4f53\u7684\u5b9e\u73b0\u4e2d<strong style=\"outline: 0px;\">\u52a0\u4e86\u5c42\u76ae\u6765\u88c5\u9970<\/strong>\u00a0\u800c\u5df2\u3002<\/p>\n<blockquote style=\"margin-top: 20px; margin-bottom: 20px; padding: 10px 10px 10px 20px; outline: 0px; border-left-color: rgba(0, 0, 0, 0.65); color: #6a737d; font-size: 0.9em; border-top: none; border-bottom: none; overflow: auto; border-right: 1px solid rgba(0, 0, 0, 0.65); background: #f9f9f9;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; font-size: 14px; color: black; line-height: 26px;\">\u6ce8\u610f\u8fd9\u6bb5\u8bdd\u4e2d\u6df7\u6742\u5728\u5404\u4e2a\u540d\u8bcd\u4e2d\u7684 Component \u548c Decorator\uff0c\u522b\u641e\u6df7\u4e86\u3002<\/p>\n<\/blockquote>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u4e0b\u9762\u6765\u770b\u770b\u4e00\u4e2a\u4f8b\u5b50\uff0c\u5148\u628a\u88c5\u9970\u6a21\u5f0f\u5f04\u6e05\u695a\uff0c\u7136\u540e\u518d\u4ecb\u7ecd\u4e0b java io \u4e2d\u7684\u88c5\u9970\u6a21\u5f0f\u7684\u5e94\u7528\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6700\u8fd1\u5927\u8857\u4e0a\u6d41\u884c\u8d77\u6765\u4e86\u201c\u5feb\u4e50\u67e0\u6aac\u201d\uff0c\u6211\u4eec\u628a\u5feb\u4e50\u67e0\u6aac\u7684\u996e\u6599\u5206\u4e3a\u4e09\u7c7b\uff1a\u7ea2\u8336\u3001\u7eff\u8336\u3001\u5496\u5561\uff0c\u5728\u8fd9\u4e09\u5927\u7c7b\u7684\u57fa\u7840\u4e0a\uff0c\u53c8\u589e\u52a0\u4e86\u8bb8\u591a\u7684\u53e3\u5473\uff0c\u4ec0\u4e48\u91d1\u6854\u67e0\u6aac\u7ea2\u8336\u3001\u91d1\u6854\u67e0\u6aac\u73cd\u73e0\u7eff\u8336\u3001\u8292\u679c\u7ea2\u8336\u3001\u8292\u679c\u7eff\u8336\u3001\u8292\u679c\u73cd\u73e0\u7ea2\u8336\u3001\u70e4\u73cd\u73e0\u7ea2\u8336\u3001\u70e4\u73cd\u73e0\u8292\u679c\u7eff\u8336\u3001\u6930\u9999\u80da\u82bd\u5496\u5561\u3001\u7126\u7cd6\u53ef\u53ef\u5496\u5561\u7b49\u7b49\uff0c\u6bcf\u5bb6\u5e97\u90fd\u6709\u5f88\u957f\u7684\u83dc\u5355\uff0c\u4f46\u662f\u4ed4\u7ec6\u770b\u4e0b\uff0c\u5176\u5b9e\u539f\u6599\u4e5f\u6ca1\u51e0\u6837\uff0c\u4f46\u662f\u53ef\u4ee5\u642d\u914d\u51fa\u5f88\u591a\u7ec4\u5408\uff0c\u5982\u679c\u987e\u5ba2\u9700\u8981\uff0c\u5f88\u591a\u6ca1\u51fa\u73b0\u5728\u83dc\u5355\u4e2d\u7684\u996e\u6599\u4ed6\u4eec\u4e5f\u662f\u53ef\u4ee5\u505a\u7684\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u7ea2\u8336\u3001\u7eff\u8336\u3001\u5496\u5561\u662f\u6700\u57fa\u7840\u7684\u996e\u6599\uff0c\u5176\u4ed6\u7684\u50cf\u91d1\u6854\u67e0\u6aac\u3001\u8292\u679c\u3001\u73cd\u73e0\u3001\u6930\u679c\u3001\u7126\u7cd6\u7b49\u90fd\u5c5e\u4e8e\u88c5\u9970\u7528\u7684\u3002\u5f53\u7136\uff0c\u5728\u5f00\u53d1\u4e2d\uff0c\u6211\u4eec\u786e\u5b9e\u53ef\u4ee5\u50cf\u95e8\u5e97\u4e00\u6837\uff0c\u5f00\u53d1\u8fd9\u4e9b\u7c7b\uff1aLemonBlackTea\u3001LemonGreenTea\u3001MangoBlackTea\u3001MangoLemonGreenTea......\u4f46\u662f\uff0c\u5f88\u5feb\u6211\u4eec\u5c31\u53d1\u73b0\uff0c\u8fd9\u6837\u5b50\u5e72\u80af\u5b9a\u662f\u4e0d\u884c\u7684\uff0c\u8fd9\u4f1a\u5bfc\u81f4\u6211\u4eec\u9700\u8981\u7ec4\u5408\u51fa\u6240\u6709\u7684\u53ef\u80fd\uff0c\u800c\u4e14\u5982\u679c\u5ba2\u4eba\u9700\u8981\u5728\u7ea2\u8336\u4e2d\u52a0\u53cc\u4efd\u67e0\u6aac\u600e\u4e48\u529e\uff1f\u4e09\u4efd\u67e0\u6aac\u600e\u4e48\u529e\uff1f<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u4e0d\u8bf4\u5e9f\u8bdd\u4e86\uff0c\u4e0a\u4ee3\u7801\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u9996\u5148\uff0c\u5b9a\u4e49\u996e\u6599\u62bd\u8c61\u57fa\u7c7b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">abstract<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Beverage<\/span>\u00a0<\/span>{\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; letter-spacing: 0px; color: #57a64a; font-style: italic;\">\/\/\u00a0\u8fd4\u56de\u63cf\u8ff0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"outline: 0px; letter-spacing: 0px; color: #57a64a; font-style: italic;\">public\u00a0abstract\u00a0String\u00a0getDescription();\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/\u00a0\u8fd4\u56de\u4ef7\u683c\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0public\u00a0abstract\u00a0double\u00a0cost();}<\/span><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u7136\u540e\u662f\u4e09\u4e2a\u57fa\u7840\u996e\u6599\u5b9e\u73b0\u7c7b\uff0c\u7ea2\u8336\u3001\u7eff\u8336\u548c\u5496\u5561\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">BlackTea<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">extends<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Beverage<\/span>\u00a0<\/span>{\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0String\u00a0<span style=\"outline: 0px; line-height: 26px;\">getDescription<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u7ea2\u8336\"<\/span>;\u00a0\u00a0\u00a0\u00a0}\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">double<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">cost<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\">10<\/span>;\u00a0\u00a0\u00a0\u00a0}}<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">GreenTea<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">extends<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Beverage<\/span>\u00a0<\/span>{\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0String\u00a0<span style=\"outline: 0px; line-height: 26px;\">getDescription<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u7eff\u8336\"<\/span>;\u00a0\u00a0\u00a0\u00a0}\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">double<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">cost<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\">11<\/span>;\u00a0\u00a0\u00a0\u00a0}}...<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5496\u5561\u7701\u7565<\/span><br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5b9a\u4e49\u8c03\u6599\uff0c\u4e5f\u5c31\u662f\u88c5\u9970\u8005\u7684\u57fa\u7c7b\uff0c\u6b64\u7c7b\u5fc5\u987b\u7ee7\u627f\u81ea Beverage\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u8c03\u6599public\u00a0abstract\u00a0class\u00a0Condiment\u00a0extends\u00a0Beverage\u00a0{}<\/span><br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u7136\u540e\u6211\u4eec\u6765\u5b9a\u4e49\u67e0\u6aac\u3001\u8292\u679c\u7b49\u5177\u4f53\u7684\u8c03\u6599\uff0c\u5b83\u4eec\u5c5e\u4e8e\u88c5\u9970\u8005\uff0c\u6beb\u65e0\u7591\u95ee\uff0c\u8fd9\u4e9b\u8c03\u6599\u80af\u5b9a\u90fd\u9700\u8981\u7ee7\u627f\u8c03\u6599 Condiment \u7c7b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Lemon<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">extends<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Condiment<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0Beverage\u00a0bevarage;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u8fd9\u91cc\u5f88\u5173\u952e\uff0c\u9700\u8981\u4f20\u5165\u5177\u4f53\u7684\u996e\u6599\uff0c\u5982\u9700\u8981\u4f20\u5165\u6ca1\u6709\u88ab\u88c5\u9970\u7684\u7ea2\u8336\u6216\u7eff\u8336\uff0c<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5f53\u7136\u4e5f\u53ef\u4ee5\u4f20\u5165\u5df2\u7ecf\u88c5\u9970\u597d\u7684\u8292\u679c\u7eff\u8336\uff0c\u8fd9\u6837\u53ef\u4ee5\u505a\u8292\u679c\u67e0\u6aac\u7eff\u8336<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">Lemon<\/span><span style=\"outline: 0px; line-height: 26px;\">(Beverage\u00a0bevarage)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.bevarage\u00a0=\u00a0bevarage;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0String\u00a0<span style=\"outline: 0px; line-height: 26px;\">getDescription<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u88c5\u9970<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0bevarage.getDescription()\u00a0+\u00a0<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\",\u00a0\u52a0\u67e0\u6aac\"<\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">double<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">cost<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u88c5\u9970<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0beverage.cost()\u00a0+\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\">2<\/span>;\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u52a0\u67e0\u6aac\u9700\u8981\u00a02\u00a0\u5143<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Mango<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">extends<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Condiment<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0Beverage\u00a0bevarage;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">Mango<\/span><span style=\"outline: 0px; line-height: 26px;\">(Beverage\u00a0bevarage)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.bevarage\u00a0=\u00a0bevarage;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0String\u00a0<span style=\"outline: 0px; line-height: 26px;\">getDescription<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0bevarage.getDescription()\u00a0+\u00a0<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\",\u00a0\u52a0\u8292\u679c\"<\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">double<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">cost<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0beverage.cost()\u00a0+\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\">3<\/span>;\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u52a0\u8292\u679c\u9700\u8981\u00a03\u00a0\u5143<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/>...<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u7ed9\u6bcf\u4e00\u79cd\u8c03\u6599\u90fd\u52a0\u4e00\u4e2a\u7c7b<\/span><br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u770b\u5ba2\u6237\u7aef\u8c03\u7528\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">main<\/span><span style=\"outline: 0px; line-height: 26px;\">(String[]\u00a0args)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u4e00\u4e2a\u57fa\u7840\u996e\u6599\uff0c\u7ea2\u8336\u3001\u7eff\u8336\u6216\u5496\u5561<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0Beverage\u00a0beverage\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0GreenTea();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5f00\u59cb\u88c5\u9970<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0beverage\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Lemon(beverage);\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5148\u52a0\u4e00\u4efd\u67e0\u6aac<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0beverage\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Mongo(beverage);\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u518d\u52a0\u4e00\u4efd\u8292\u679c<\/span><br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0System.out.println(beverage.getDescription()\u00a0+\u00a0<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u00a0\u4ef7\u683c\uff1a\uffe5\"<\/span>\u00a0+\u00a0beverage.cost());<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\"\u7eff\u8336, \u52a0\u67e0\u6aac, \u52a0\u8292\u679c\u00a0\u4ef7\u683c\uff1a\uffe516\"<\/span><br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5982\u679c\u6211\u4eec\u9700\u8981\u00a0<strong style=\"outline: 0px;\">\u8292\u679c-\u73cd\u73e0-\u53cc\u4efd\u67e0\u6aac-\u7ea2\u8336<\/strong>\u00a0\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\">Beverage\u00a0beverage\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Mongo(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Pearl(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Lemon(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Lemon(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0BlackTea()))));<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u662f\u4e0d\u662f\u5f88\u53d8\u6001\uff1f<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u770b\u770b\u4e0b\u56fe\u53ef\u80fd\u4f1a\u6e05\u6670\u4e00\u4e9b\uff1a<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; outline: 0px; display: flex; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><figcaption style=\"margin-top: 5px; outline: 0px; text-align: center; color: #888888; font-size: 12px;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005427972.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-ratio=\"0.7490740740740741\" data-type=\"png\" data-w=\"1080\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005427972.png\" data-ratio=\"0.7490740740740741\" data-type=\"png\" data-w=\"1080\" \/><\/noscript><\/figcaption><\/figure>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5230\u8fd9\u91cc\uff0c\u5927\u5bb6\u5e94\u8be5\u5df2\u7ecf\u6e05\u695a\u88c5\u9970\u6a21\u5f0f\u4e86\u5427\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u4e0b\u9762\uff0c\u6211\u4eec\u518d\u6765\u8bf4\u8bf4 java IO \u4e2d\u7684\u88c5\u9970\u6a21\u5f0f\u3002\u770b\u4e0b\u56fe InputStream \u6d3e\u751f\u51fa\u6765\u7684\u90e8\u5206\u7c7b\uff1a<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; outline: 0px; display: flex; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><figcaption style=\"margin-top: 5px; outline: 0px; text-align: center; color: #888888; font-size: 12px;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005432976.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-ratio=\"0.48333333333333334\" data-type=\"png\" data-w=\"1080\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005432976.png\" data-ratio=\"0.48333333333333334\" data-type=\"png\" data-w=\"1080\" \/><\/noscript><\/figcaption><\/figure>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6211\u4eec\u77e5\u9053 InputStream \u4ee3\u8868\u4e86\u8f93\u5165\u6d41\uff0c\u5177\u4f53\u7684\u8f93\u5165\u6765\u6e90\u53ef\u4ee5\u662f\u6587\u4ef6\uff08FileInputStream\uff09\u3001\u7ba1\u9053\uff08PipedInputStream\uff09\u3001\u6570\u7ec4\uff08ByteArrayInputStream\uff09\u7b49\uff0c\u8fd9\u4e9b\u5c31\u50cf\u524d\u9762\u5976\u8336\u7684\u4f8b\u5b50\u4e2d\u7684\u7ea2\u8336\u3001\u7eff\u8336\uff0c\u5c5e\u4e8e\u57fa\u7840\u8f93\u5165\u6d41\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">FilterInputStream \u627f\u63a5\u4e86\u88c5\u9970\u6a21\u5f0f\u7684\u5173\u952e\u8282\u70b9\uff0c\u5b83\u7684\u5b9e\u73b0\u7c7b\u662f\u4e00\u7cfb\u5217\u88c5\u9970\u5668\uff0c\u6bd4\u5982 BufferedInputStream \u4ee3\u8868\u7528\u7f13\u51b2\u6765\u88c5\u9970\uff0c\u4e5f\u5c31\u4f7f\u5f97\u8f93\u5165\u6d41\u5177\u6709\u4e86\u7f13\u51b2\u7684\u529f\u80fd\uff0cLineNumberInputStream \u4ee3\u8868\u7528\u884c\u53f7\u6765\u88c5\u9970\uff0c\u5728\u64cd\u4f5c\u7684\u65f6\u5019\u5c31\u53ef\u4ee5\u53d6\u5f97\u884c\u53f7\u4e86\uff0cDataInputStream \u7684\u88c5\u9970\uff0c\u4f7f\u5f97\u6211\u4eec\u53ef\u4ee5\u4ece\u8f93\u5165\u6d41\u8f6c\u6362\u4e3a java \u4e2d\u7684\u57fa\u672c\u7c7b\u578b\u503c\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5f53\u7136\uff0c\u5728 java IO \u4e2d\uff0c\u5982\u679c\u6211\u4eec\u4f7f\u7528\u88c5\u9970\u5668\u7684\u8bdd\uff0c\u5c31\u4e0d\u592a\u9002\u5408\u9762\u5411\u63a5\u53e3\u7f16\u7a0b\u4e86\uff0c\u5982\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\">InputStream\u00a0inputStream\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0LineNumberInputStream(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0BufferedInputStream(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0FileInputStream(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\"<\/span>)));<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8fd9\u6837\u7684\u7ed3\u679c\u662f\uff0cInputStream \u8fd8\u662f\u4e0d\u5177\u6709\u8bfb\u53d6\u884c\u53f7\u7684\u529f\u80fd\uff0c\u56e0\u4e3a\u8bfb\u53d6\u884c\u53f7\u7684\u65b9\u6cd5\u5b9a\u4e49\u5728 LineNumberInputStream \u7c7b\u4e2d\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6211\u4eec\u5e94\u8be5\u50cf\u4e0b\u9762\u8fd9\u6837\u4f7f\u7528\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\">DataInputStream\u00a0is\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0DataInputStream(<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0BufferedInputStream(<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0FileInputStream(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\"<\/span>)));<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<blockquote style=\"margin-top: 20px; margin-bottom: 20px; padding: 10px 10px 10px 20px; outline: 0px; border-left-color: rgba(0, 0, 0, 0.65); color: #6a737d; font-size: 0.9em; border-top: none; border-bottom: none; overflow: auto; border-right: 1px solid rgba(0, 0, 0, 0.65); background: #f9f9f9;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; font-size: 14px; color: black; line-height: 26px;\">\u6240\u4ee5\u8bf4\u561b\uff0c\u8981\u627e\u5230\u7eaf\u7684\u4e25\u683c\u7b26\u5408\u8bbe\u8ba1\u6a21\u5f0f\u7684\u4ee3\u7801\u8fd8\u662f\u6bd4\u8f83\u96be\u7684\u3002<\/p>\n<\/blockquote>\n<h3 style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><\/h3>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px; border: 0px none initial;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; display: inline-block;\">\n<section style=\"padding-right: 10px; padding-left: 10px; outline: 0px; font-size: 16px; color: #494949;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u95e8\u9762\u6a21\u5f0f<\/span><\/p>\n<\/section>\n<section style=\"margin-top: -10px; outline: 0px; background-color: #fcb42b; height: 8px; color: #ffffff;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">\u95e8\u9762\u6a21\u5f0f\uff08\u4e5f\u53eb\u5916\u89c2\u6a21\u5f0f\uff0cFacade Pattern\uff09\u5728\u8bb8\u591a\u6e90\u7801\u4e2d\u6709\u4f7f\u7528\uff0c\u6bd4\u5982 slf4j \u5c31\u53ef\u4ee5\u7406\u89e3\u4e3a\u662f\u95e8\u9762\u6a21\u5f0f\u7684\u5e94\u7528\u3002<\/span><span style=\"outline: 0px; letter-spacing: 0px;\">\u8fd9\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u8bbe\u8ba1\u6a21\u5f0f\uff0c\u6211\u4eec\u76f4\u63a5\u4e0a\u4ee3\u7801\u518d\u8bf4\u5427\u3002<\/span><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u9996\u5148\uff0c\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u63a5\u53e3\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">interface<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Shape<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">draw<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span><\/span>;<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5b9a\u4e49\u51e0\u4e2a\u5b9e\u73b0\u7c7b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Circle<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">implements<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Shape<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #9b9b9b; line-height: 26px;\">@Override<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">draw<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"Circle::draw()\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Rectangle<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">implements<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Shape<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #9b9b9b; line-height: 26px;\">@Override<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">draw<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"Rectangle::draw()\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5ba2\u6237\u7aef\u8c03\u7528\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">main<\/span><span style=\"outline: 0px; line-height: 26px;\">(String[]\u00a0args)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u753b\u4e00\u4e2a\u5706\u5f62<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Shape\u00a0circle\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Circle();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0circle.draw();<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u753b\u4e00\u4e2a\u957f\u65b9\u5f62<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Shape\u00a0rectangle\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Rectangle();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0rectangle.draw();<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u4ee5\u4e0a\u662f\u6211\u4eec\u5e38\u5199\u7684\u4ee3\u7801\uff0c\u6211\u4eec\u9700\u8981\u753b\u5706\u5c31\u8981\u5148\u5b9e\u4f8b\u5316\u5706\uff0c\u753b\u957f\u65b9\u5f62\u5c31\u9700\u8981\u5148\u5b9e\u4f8b\u5316\u4e00\u4e2a\u957f\u65b9\u5f62\uff0c\u7136\u540e\u518d\u8c03\u7528\u76f8\u5e94\u7684 draw() \u65b9\u6cd5\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u4e0b\u9762\uff0c\u6211\u4eec\u770b\u770b\u600e\u4e48\u7528\u95e8\u9762\u6a21\u5f0f\u6765\u8ba9\u5ba2\u6237\u7aef\u8c03\u7528\u66f4\u52a0\u53cb\u597d\u4e00\u4e9b\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6211\u4eec\u5148\u5b9a\u4e49\u4e00\u4e2a\u95e8\u9762\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">ShapeMaker<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0Shape\u00a0circle;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0Shape\u00a0rectangle;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0Shape\u00a0square;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">ShapeMaker<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0circle\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Circle();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0rectangle\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Rectangle();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0square\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Square();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/**<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0*\u00a0\u4e0b\u9762\u5b9a\u4e49\u4e00\u5806\u65b9\u6cd5\uff0c\u5177\u4f53\u5e94\u8be5\u8c03\u7528\u4ec0\u4e48\u65b9\u6cd5\uff0c\u7531\u8fd9\u4e2a\u95e8\u9762\u6765\u51b3\u5b9a<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0*\/<\/span><br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">drawCircle<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span><\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0circle.draw();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">drawRectangle<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span><\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0rectangle.draw();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">drawSquare<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span><\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0square.draw();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u770b\u770b\u73b0\u5728\u5ba2\u6237\u7aef\u600e\u4e48\u8c03\u7528\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">main<\/span><span style=\"outline: 0px; line-height: 26px;\">(String[]\u00a0args)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0ShapeMaker\u00a0shapeMaker\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0ShapeMaker();<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5ba2\u6237\u7aef\u8c03\u7528\u73b0\u5728\u66f4\u52a0\u6e05\u6670\u4e86<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0shapeMaker.drawCircle();<br style=\"outline: 0px;\" \/>\u00a0\u00a0shapeMaker.drawRectangle();<br style=\"outline: 0px;\" \/>\u00a0\u00a0shapeMaker.drawSquare();<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u95e8\u9762\u6a21\u5f0f\u7684\u4f18\u70b9\u663e\u800c\u6613\u89c1\uff0c\u5ba2\u6237\u7aef\u4e0d\u518d\u9700\u8981\u5173\u6ce8\u5b9e\u4f8b\u5316\u65f6\u5e94\u8be5\u4f7f\u7528\u54ea\u4e2a\u5b9e\u73b0\u7c7b\uff0c\u76f4\u63a5\u8c03\u7528\u95e8\u9762\u63d0\u4f9b\u7684\u65b9\u6cd5\u5c31\u53ef\u4ee5\u4e86\uff0c\u56e0\u4e3a\u95e8\u9762\u7c7b\u63d0\u4f9b\u7684\u65b9\u6cd5\u7684\u65b9\u6cd5\u540d\u5bf9\u4e8e\u5ba2\u6237\u7aef\u6765\u8bf4\u5df2\u7ecf\u5f88\u53cb\u597d\u4e86\u3002<\/p>\n<h3 style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><\/h3>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px; border: 0px none initial;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; display: inline-block;\">\n<section style=\"padding-right: 10px; padding-left: 10px; outline: 0px; font-size: 16px; color: #494949;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u7ec4\u5408\u6a21\u5f0f<\/span><\/p>\n<\/section>\n<section style=\"margin-top: -10px; outline: 0px; background-color: #fcb42b; height: 8px; color: #ffffff;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">\u7ec4\u5408\u6a21\u5f0f\u7528\u4e8e\u8868\u793a\u5177\u6709\u5c42\u6b21\u7ed3\u6784\u7684\u6570\u636e\uff0c\u4f7f\u5f97\u6211\u4eec\u5bf9\u5355\u4e2a\u5bf9\u8c61\u548c\u7ec4\u5408\u5bf9\u8c61\u7684\u8bbf\u95ee\u5177\u6709\u4e00\u81f4\u6027\u3002<\/span><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u76f4\u63a5\u770b\u4e00\u4e2a\u4f8b\u5b50\u5427\uff0c\u6bcf\u4e2a\u5458\u5de5\u90fd\u6709\u59d3\u540d\u3001\u90e8\u95e8\u3001\u85aa\u6c34\u8fd9\u4e9b\u5c5e\u6027\uff0c\u540c\u65f6\u8fd8\u6709\u4e0b\u5c5e\u5458\u5de5\u96c6\u5408\uff08\u867d\u7136\u53ef\u80fd\u96c6\u5408\u4e3a\u7a7a\uff09\uff0c\u800c\u4e0b\u5c5e\u5458\u5de5\u548c\u81ea\u5df1\u7684\u7ed3\u6784\u662f\u4e00\u6837\u7684\uff0c\u4e5f\u6709\u59d3\u540d\u3001\u90e8\u95e8\u8fd9\u4e9b\u5c5e\u6027\uff0c\u540c\u65f6\u4e5f\u6709\u4ed6\u4eec\u7684\u4e0b\u5c5e\u5458\u5de5\u96c6\u5408\u3002<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Employee<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0String\u00a0name;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0String\u00a0dept;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0salary;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0List&lt;Employee&gt;\u00a0subordinates;\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u4e0b\u5c5e<\/span><br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">Employee<\/span><span style=\"outline: 0px; line-height: 26px;\">(String\u00a0name,String\u00a0dept,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0sal)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.name\u00a0=\u00a0name;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.dept\u00a0=\u00a0dept;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.salary\u00a0=\u00a0sal;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0subordinates\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0ArrayList&lt;Employee&gt;();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">add<\/span><span style=\"outline: 0px; line-height: 26px;\">(Employee\u00a0e)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0subordinates.add(e);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">remove<\/span><span style=\"outline: 0px; line-height: 26px;\">(Employee\u00a0e)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0subordinates.remove(e);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0List&lt;Employee&gt;\u00a0<span style=\"outline: 0px; line-height: 26px;\">getSubordinates<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span><\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0subordinates;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0String\u00a0<span style=\"outline: 0px; line-height: 26px;\">toString<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span><\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"Employee\u00a0:[\u00a0Name\u00a0:\u00a0\"<\/span>\u00a0+\u00a0name\u00a0+\u00a0<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\",\u00a0dept\u00a0:\u00a0\"<\/span>\u00a0+\u00a0dept\u00a0+\u00a0<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\",\u00a0salary\u00a0:\"<\/span>\u00a0+\u00a0salary+<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u00a0]\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u901a\u5e38\uff0c\u8fd9\u79cd\u7c7b\u9700\u8981\u5b9a\u4e49 add(node)\u3001remove(node)\u3001getChildren() \u8fd9\u4e9b\u65b9\u6cd5\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8fd9\u8bf4\u7684\u5176\u5b9e\u5c31\u662f\u7ec4\u5408\u6a21\u5f0f\uff0c\u8fd9\u79cd\u7b80\u5355\u7684\u6a21\u5f0f\u6211\u5c31\u4e0d\u505a\u8fc7\u591a\u4ecb\u7ecd\u4e86\uff0c\u76f8\u4fe1\u5404\u4f4d\u8bfb\u8005\u4e5f\u4e0d\u559c\u6b22\u770b\u6211\u5199\u5e9f\u8bdd\u3002<\/p>\n<h3 style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><\/h3>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px; border: 0px none initial;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; display: inline-block;\">\n<section style=\"padding-right: 10px; padding-left: 10px; outline: 0px; font-size: 16px; color: #494949;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u4eab\u5143\u6a21\u5f0f<\/span><\/p>\n<\/section>\n<section style=\"margin-top: -10px; outline: 0px; background-color: #fcb42b; height: 8px; color: #ffffff;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">\u82f1\u6587\u662f Flyweight Pattern\uff0c\u4e0d\u77e5\u9053\u662f\u8c01\u6700\u5148\u7ffb\u8bd1\u7684\u8fd9\u4e2a\u8bcd\uff0c\u611f\u89c9\u8fd9\u7ffb\u8bd1\u771f\u7684\u4e0d\u597d\u7406\u89e3\uff0c\u6211\u4eec\u8bd5\u7740\u5f3a\u884c\u5173\u8054\u8d77\u6765\u5427\u3002<\/span><span style=\"outline: 0px; letter-spacing: 0px;\">Flyweight \u662f\u8f7b\u91cf\u7ea7\u7684\u610f\u601d\uff0c\u4eab\u5143\u5206\u5f00\u6765\u8bf4\u5c31\u662f \u5171\u4eab \u5143\u5668\u4ef6\uff0c\u4e5f\u5c31\u662f\u590d\u7528\u5df2\u7ecf\u751f\u6210\u7684\u5bf9\u8c61\uff0c\u8fd9\u79cd\u505a\u6cd5\u5f53\u7136\u4e5f\u5c31\u662f\u8f7b\u91cf\u7ea7\u7684\u4e86\u3002<\/span><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u590d\u7528\u5bf9\u8c61\u6700\u7b80\u5355\u7684\u65b9\u5f0f\u662f\uff0c\u7528\u4e00\u4e2a HashMap \u6765\u5b58\u653e\u6bcf\u6b21\u65b0\u751f\u6210\u7684\u5bf9\u8c61\u3002\u6bcf\u6b21\u9700\u8981\u4e00\u4e2a\u5bf9\u8c61\u7684\u65f6\u5019\uff0c\u5148\u5230 HashMap \u4e2d\u770b\u770b\u6709\u6ca1\u6709\uff0c\u5982\u679c\u6ca1\u6709\uff0c\u518d\u751f\u6210\u65b0\u7684\u5bf9\u8c61\uff0c\u7136\u540e\u5c06\u8fd9\u4e2a\u5bf9\u8c61\u653e\u5165 HashMap \u4e2d\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8fd9\u79cd\u7b80\u5355\u7684\u4ee3\u7801\u6211\u5c31\u4e0d\u6f14\u793a\u4e86\u3002<\/p>\n<h3 style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><\/h3>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px; border: 0px none initial;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; display: inline-block;\">\n<section style=\"padding-right: 10px; padding-left: 10px; outline: 0px; font-size: 16px; color: #494949;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u7ed3\u6784\u578b\u6a21\u5f0f\u603b\u7ed3<\/span><\/p>\n<\/section>\n<section style=\"margin-top: -10px; outline: 0px; background-color: #fcb42b; height: 8px; color: #ffffff;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">\u524d\u9762\uff0c\u6211\u4eec\u8bf4\u4e86\u4ee3\u7406\u6a21\u5f0f\u3001\u9002\u914d\u5668\u6a21\u5f0f\u3001\u6865\u6881\u6a21\u5f0f\u3001\u88c5\u9970\u6a21\u5f0f\u3001\u95e8\u9762\u6a21\u5f0f\u3001\u7ec4\u5408\u6a21\u5f0f\u548c\u4eab\u5143\u6a21\u5f0f\u3002<\/span><span style=\"outline: 0px; letter-spacing: 0px;\">\u8bfb\u8005\u662f\u5426\u53ef\u4ee5\u5206\u522b\u628a\u8fd9\u51e0\u4e2a\u6a21\u5f0f\u8bf4\u6e05\u695a\u4e86\u5462\uff1f<\/span><span style=\"outline: 0px; letter-spacing: 0px;\">\u5728\u8bf4\u5230\u8fd9\u4e9b\u6a21\u5f0f\u7684\u65f6\u5019\uff0c\u5fc3\u4e2d\u662f\u5426\u6709\u4e00\u4e2a\u6e05\u6670\u7684\u56fe\u6216\u5904\u7406\u6d41\u7a0b\u5728\u8111\u6d77\u91cc\u5462\uff1f<\/span><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u4ee3\u7406\u6a21\u5f0f\u662f\u505a\u65b9\u6cd5\u589e\u5f3a\u7684\uff0c\u9002\u914d\u5668\u6a21\u5f0f\u662f\u628a\u9e21\u5305\u88c5\u6210\u9e2d\u8fd9\u79cd\u7528\u6765\u9002\u914d\u63a5\u53e3\u7684\uff0c\u6865\u6881\u6a21\u5f0f\u505a\u5230\u4e86\u5f88\u597d\u7684\u89e3\u8026\uff0c\u88c5\u9970\u6a21\u5f0f\u4ece\u540d\u5b57\u4e0a\u5c31\u770b\u5f97\u51fa\u6765\uff0c\u9002\u5408\u4e8e\u88c5\u9970\u7c7b\u6216\u8005\u8bf4\u662f\u589e\u5f3a\u7c7b\u7684\u573a\u666f\uff0c\u95e8\u9762\u6a21\u5f0f\u7684\u4f18\u70b9\u662f\u5ba2\u6237\u7aef\u4e0d\u9700\u8981\u5173\u5fc3\u5b9e\u4f8b\u5316\u8fc7\u7a0b\uff0c\u53ea\u8981\u8c03\u7528\u9700\u8981\u7684\u65b9\u6cd5\u5373\u53ef\uff0c\u7ec4\u5408\u6a21\u5f0f\u7528\u4e8e\u63cf\u8ff0\u5177\u6709\u5c42\u6b21\u7ed3\u6784\u7684\u6570\u636e\uff0c\u4eab\u5143\u6a21\u5f0f\u662f\u4e3a\u4e86\u5728\u7279\u5b9a\u7684\u573a\u666f\u4e2d\u7f13\u5b58\u5df2\u7ecf\u521b\u5efa\u7684\u5bf9\u8c61\uff0c\u7528\u4e8e\u63d0\u9ad8\u6027\u80fd\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<blockquote style=\"margin: 5px auto; padding-top: 0px; padding-left: 0px; outline: 0px; color: #4499e7; font-size: 16px; line-height: 25.6px; border: 0px none #4499e7;\">\n<section style=\"margin-right: auto; margin-left: auto; outline: 0px; border-color: #4499e7;\">\n<section style=\"margin-right: auto; margin-left: auto; outline: 0px; border-color: #4499e7;\">\n<blockquote style=\"margin: 5px auto; padding-top: 0px; padding-left: 0px; outline: 0px; color: var(--weui-fg-1); border: 0px none #4499e7;\">\n<section style=\"margin-right: auto; margin-left: auto; outline: 0px; text-align: center; border-color: #4499e7;\">\n<section style=\"margin-right: auto; margin-bottom: -38px; margin-left: auto; padding-right: 15px; padding-left: 15px; outline: 0px; display: inline-block; background-color: #4499e7; border-color: #4499e7;\">\n<p style=\"margin-top: 5px; margin-bottom: 5px; outline: 0px; color: #4499e7; border-color: #4499e7;\"><span style=\"outline: 0px; font-family: Arial, Helvetica, sans-serif;\"><strong style=\"outline: 0px;\"><span style=\"outline: 0px; border-color: #4499e7; color: #ffffff; font-size: 16px;\">\u884c\u4e3a\u578b\u6a21\u5f0f<\/span><\/strong><\/span><\/p>\n<\/section>\n<section style=\"margin: -40px 25px 50px; outline: 0px; border-color: #4499e7;\">\n<section style=\"margin-top: 3px; padding-top: 10px; padding-bottom: 10px; outline: 0px; display: inline-block; width: 495px; color: #4499e7; float: left; border-color: #4499e7;\">\n<section style=\"margin-top: 1em; outline: 0px; clear: both; border: 0px none #4499e7;\">\n<section style=\"margin-bottom: -3px; outline: 0px; float: right; border-color: #4499e7; width: 6px; border-radius: 50%; background-color: #4499e7; height: 6px !important;\"><\/section>\n<section style=\"margin-bottom: -2px; outline: 0px; text-align: left; border-color: #4499e7; width: 6px; border-radius: 50%; background-color: #4499e7; height: 6px !important;\"><\/section>\n<section style=\"margin-top: -20px; outline: 0px; text-decoration: inherit; border-color: #4499e7;\">\n<section style=\"outline: 0px; border-top: 1px solid #4499e7; width: 495px; float: left; border-right-color: #4499e7; border-bottom-color: #4499e7; border-left-color: #4499e7;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/blockquote>\n<\/section>\n<\/section>\n<\/blockquote>\n<\/section>\n<p style=\"outline: 0px;\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u884c\u4e3a\u578b\u6a21\u5f0f\u5173\u6ce8\u7684\u662f\u5404\u4e2a\u7c7b\u4e4b\u95f4\u7684\u76f8\u4e92\u4f5c\u7528\uff0c\u5c06\u804c\u8d23\u5212\u5206\u6e05\u695a\uff0c\u4f7f\u5f97\u6211\u4eec\u7684\u4ee3\u7801\u66f4\u52a0\u5730\u6e05\u6670\u3002<\/p>\n<h3 style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><\/h3>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px; border: 0px none initial;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; display: inline-block;\">\n<section style=\"padding-right: 10px; padding-left: 10px; outline: 0px; font-size: 16px; color: #494949;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u7b56\u7565\u6a21\u5f0f<\/span><\/p>\n<\/section>\n<section style=\"margin-top: -10px; outline: 0px; background-color: #fcb42b; height: 8px; color: #ffffff;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">\u7b56\u7565\u6a21\u5f0f\u592a\u5e38\u7528\u4e86\uff0c\u6240\u4ee5\u628a\u5b83\u653e\u5230\u6700\u524d\u9762\u8fdb\u884c\u4ecb\u7ecd\u3002<\/span><span style=\"outline: 0px; letter-spacing: 0px;\">\u5b83\u6bd4\u8f83\u7b80\u5355\uff0c\u6211\u5c31\u4e0d\u5e9f\u8bdd\uff0c\u76f4\u63a5\u7528\u4ee3\u7801\u8bf4\u4e8b\u5427\u3002<\/span><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u4e0b\u9762\u8bbe\u8ba1\u7684\u573a\u666f\u662f\uff0c\u6211\u4eec\u9700\u8981\u753b\u4e00\u4e2a\u56fe\u5f62\uff0c\u53ef\u9009\u7684\u7b56\u7565\u5c31\u662f\u7528\u7ea2\u8272\u7b14\u6765\u753b\uff0c\u8fd8\u662f\u7eff\u8272\u7b14\u6765\u753b\uff0c\u6216\u8005\u84dd\u8272\u7b14\u6765\u753b\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u9996\u5148\uff0c\u5148\u5b9a\u4e49\u4e00\u4e2a\u7b56\u7565\u63a5\u53e3\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">interface<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Strategy<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">draw<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0radius,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0x,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0y)<\/span><\/span>;<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u7136\u540e\u6211\u4eec\u5b9a\u4e49\u5177\u4f53\u7684\u51e0\u4e2a\u7b56\u7565\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">RedPen<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">implements<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Strategy<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #9b9b9b; line-height: 26px;\">@Override<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">draw<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0radius,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0x,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0y)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u7528\u7ea2\u8272\u7b14\u753b\u56fe\uff0cradius:\"<\/span>\u00a0+\u00a0radius\u00a0+\u00a0<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\",\u00a0x:\"<\/span>\u00a0+\u00a0x\u00a0+\u00a0<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\",\u00a0y:\"<\/span>\u00a0+\u00a0y);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">GreenPen<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">implements<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Strategy<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #9b9b9b; line-height: 26px;\">@Override<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">draw<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0radius,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0x,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0y)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u7528\u7eff\u8272\u7b14\u753b\u56fe\uff0cradius:\"<\/span>\u00a0+\u00a0radius\u00a0+\u00a0<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\",\u00a0x:\"<\/span>\u00a0+\u00a0x\u00a0+\u00a0<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\",\u00a0y:\"<\/span>\u00a0+\u00a0y);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">BluePen<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">implements<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Strategy<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #9b9b9b; line-height: 26px;\">@Override<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">draw<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0radius,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0x,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0y)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u7528\u84dd\u8272\u7b14\u753b\u56fe\uff0cradius:\"<\/span>\u00a0+\u00a0radius\u00a0+\u00a0<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\",\u00a0x:\"<\/span>\u00a0+\u00a0x\u00a0+\u00a0<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\",\u00a0y:\"<\/span>\u00a0+\u00a0y);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u4f7f\u7528\u7b56\u7565\u7684\u7c7b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Context<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0Strategy\u00a0strategy;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">Context<\/span><span style=\"outline: 0px; line-height: 26px;\">(Strategy\u00a0strategy)<\/span><\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.strategy\u00a0=\u00a0strategy;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">executeDraw<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0radius,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0x,\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0y)<\/span><\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0strategy.draw(radius,\u00a0x,\u00a0y);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5ba2\u6237\u7aef\u6f14\u793a\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">main<\/span><span style=\"outline: 0px; line-height: 26px;\">(String[]\u00a0args)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0Context\u00a0context\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Context(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0BluePen());\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u4f7f\u7528\u7eff\u8272\u7b14\u6765\u753b<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0context.executeDraw(<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\">10<\/span>,\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\">0<\/span>,\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\">0<\/span>);<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u653e\u5230\u4e00\u5f20\u56fe\u4e0a\uff0c\u8ba9\u5927\u5bb6\u770b\u5f97\u6e05\u6670\u4e9b\uff1a<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; outline: 0px; display: flex; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><figcaption style=\"margin-top: 5px; outline: 0px; text-align: center; color: #888888; font-size: 12px;\"><\/figcaption><\/figure>\n<p style=\"outline: 0px;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005435525.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-ratio=\"0.7490740740740741\" data-type=\"png\" data-w=\"1080\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005435525.png\" data-ratio=\"0.7490740740740741\" data-type=\"png\" data-w=\"1080\" \/><\/noscript><\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; outline: 0px; display: flex; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8fd9\u4e2a\u65f6\u5019\uff0c\u5927\u5bb6\u6709\u6ca1\u6709\u8054\u60f3\u5230\u7ed3\u6784\u578b\u6a21\u5f0f\u4e2d\u7684\u6865\u6881\u6a21\u5f0f\uff0c\u5b83\u4eec\u5176\u5b9e\u975e\u5e38\u76f8\u4f3c\uff0c\u6211\u628a\u6865\u6881\u6a21\u5f0f\u7684\u56fe\u62ff\u8fc7\u6765\u5927\u5bb6\u5bf9\u6bd4\u4e0b\uff1a<\/figure>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; outline: 0px; display: flex; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><figcaption style=\"margin-top: 5px; outline: 0px; text-align: center; color: #888888; font-size: 12px;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005439332.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-ratio=\"0.75\" data-type=\"png\" data-w=\"1080\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"outline: 0px; width: 677px !important; visibility: visible !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005439332.png\" data-ratio=\"0.75\" data-type=\"png\" data-w=\"1080\" \/><\/noscript><\/figcaption><\/figure>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8981\u6211\u8bf4\u7684\u8bdd\uff0c\u5b83\u4eec\u975e\u5e38\u76f8\u4f3c\uff0c\u6865\u6881\u6a21\u5f0f\u5728\u5de6\u4fa7\u52a0\u4e86\u4e00\u5c42\u62bd\u8c61\u800c\u5df2\u3002\u6865\u6881\u6a21\u5f0f\u7684\u8026\u5408\u66f4\u4f4e\uff0c\u7ed3\u6784\u66f4\u590d\u6742\u4e00\u4e9b\u3002<\/p>\n<h3 style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><\/h3>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px; border: 0px none initial;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; display: inline-block;\">\n<section style=\"padding-right: 10px; padding-left: 10px; outline: 0px; font-size: 16px; color: #494949;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u89c2\u5bdf\u8005\u6a21\u5f0f<\/span><\/p>\n<\/section>\n<section style=\"margin-top: -10px; outline: 0px; background-color: #fcb42b; height: 8px; color: #ffffff;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">\u89c2\u5bdf\u8005\u6a21\u5f0f\u5bf9\u4e8e\u6211\u4eec\u6765\u8bf4\uff0c\u771f\u662f\u518d\u7b80\u5355\u4e0d\u8fc7\u4e86\u3002<\/span><span style=\"outline: 0px; letter-spacing: 0px;\">\u65e0\u5916\u4e4e\u4e24\u4e2a\u64cd\u4f5c\uff0c\u89c2\u5bdf\u8005\u8ba2\u9605\u81ea\u5df1\u5173\u5fc3\u7684\u4e3b\u9898\u548c\u4e3b\u9898\u6709\u6570\u636e\u53d8\u5316\u540e\u901a\u77e5\u89c2\u5bdf\u8005\u4eec\u3002<\/span><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u9996\u5148\uff0c\u9700\u8981\u5b9a\u4e49\u4e3b\u9898\uff0c\u6bcf\u4e2a\u4e3b\u9898\u9700\u8981\u6301\u6709\u89c2\u5bdf\u8005\u5217\u8868\u7684\u5f15\u7528\uff0c\u7528\u4e8e\u5728\u6570\u636e\u53d8\u66f4\u7684\u65f6\u5019\u901a\u77e5\u5404\u4e2a\u89c2\u5bdf\u8005\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Subject<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0List&lt;Observer&gt;\u00a0observers\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0ArrayList&lt;Observer&gt;();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0state;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">getState<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0state;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">setState<\/span><span style=\"outline: 0px; line-height: 26px;\">(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0state)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.state\u00a0=\u00a0state;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u6570\u636e\u5df2\u53d8\u66f4\uff0c\u901a\u77e5\u89c2\u5bdf\u8005\u4eec<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0notifyAllObservers();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u6ce8\u518c\u89c2\u5bdf\u8005<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">attach<\/span><span style=\"outline: 0px; line-height: 26px;\">(Observer\u00a0observer)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0observers.add(observer);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u901a\u77e5\u89c2\u5bdf\u8005\u4eec<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">notifyAllObservers<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">for<\/span>\u00a0(Observer\u00a0observer\u00a0:\u00a0observers)\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0observer.update();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5b9a\u4e49\u89c2\u5bdf\u8005\u63a5\u53e3\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">abstract<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Observer<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">protected<\/span>\u00a0Subject\u00a0subject;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">abstract<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">update<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span><\/span>;<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5176\u5b9e\u5982\u679c\u53ea\u6709\u4e00\u4e2a\u89c2\u5bdf\u8005\u7c7b\u7684\u8bdd\uff0c\u63a5\u53e3\u90fd\u4e0d\u7528\u5b9a\u4e49\u4e86\uff0c\u4e0d\u8fc7\uff0c\u901a\u5e38\u573a\u666f\u4e0b\uff0c\u65e2\u7136\u7528\u5230\u4e86\u89c2\u5bdf\u8005\u6a21\u5f0f\uff0c\u6211\u4eec\u5c31\u662f\u5e0c\u671b\u4e00\u4e2a\u4e8b\u4ef6\u51fa\u6765\u4e86\uff0c\u4f1a\u6709\u591a\u4e2a\u4e0d\u540c\u7684\u7c7b\u9700\u8981\u5904\u7406\u76f8\u5e94\u7684\u4fe1\u606f\u3002\u6bd4\u5982\uff0c\u8ba2\u5355\u4fee\u6539\u6210\u529f\u4e8b\u4ef6\uff0c\u6211\u4eec\u5e0c\u671b\u53d1\u77ed\u4fe1\u7684\u7c7b\u5f97\u5230\u901a\u77e5\u3001\u53d1\u90ae\u4ef6\u7684\u7c7b\u5f97\u5230\u901a\u77e5\u3001\u5904\u7406\u7269\u6d41\u4fe1\u606f\u7684\u7c7b\u5f97\u5230\u901a\u77e5\u7b49\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6211\u4eec\u6765\u5b9a\u4e49\u5177\u4f53\u7684\u51e0\u4e2a\u89c2\u5bdf\u8005\u7c7b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">BinaryObserver<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">extends<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Observer<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5728\u6784\u9020\u65b9\u6cd5\u4e2d\u8fdb\u884c\u8ba2\u9605\u4e3b\u9898<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">BinaryObserver<\/span><span style=\"outline: 0px; line-height: 26px;\">(Subject\u00a0subject)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.subject\u00a0=\u00a0subject;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u901a\u5e38\u5728\u6784\u9020\u65b9\u6cd5\u4e2d\u5c06\u00a0this\u00a0\u53d1\u5e03\u51fa\u53bb\u7684\u64cd\u4f5c\u4e00\u5b9a\u8981\u5c0f\u5fc3<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.subject.attach(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u8be5\u65b9\u6cd5\u7531\u4e3b\u9898\u7c7b\u5728\u6570\u636e\u53d8\u66f4\u7684\u65f6\u5019\u8fdb\u884c\u8c03\u7528<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #9b9b9b; line-height: 26px;\">@Override<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">update<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0String\u00a0result\u00a0=\u00a0Integer.toBinaryString(subject.getState());<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u8ba2\u9605\u7684\u6570\u636e\u53d1\u751f\u53d8\u5316\uff0c\u65b0\u7684\u6570\u636e\u5904\u7406\u4e3a\u4e8c\u8fdb\u5236\u503c\u4e3a\uff1a\"<\/span>\u00a0+\u00a0result);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">HexaObserver<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">extends<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Observer<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">HexaObserver<\/span><span style=\"outline: 0px; line-height: 26px;\">(Subject\u00a0subject)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.subject\u00a0=\u00a0subject;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.subject.attach(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #9b9b9b; line-height: 26px;\">@Override<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">update<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0String\u00a0result\u00a0=\u00a0Integer.toHexString(subject.getState()).toUpperCase();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u8ba2\u9605\u7684\u6570\u636e\u53d1\u751f\u53d8\u5316\uff0c\u65b0\u7684\u6570\u636e\u5904\u7406\u4e3a\u5341\u516d\u8fdb\u5236\u503c\u4e3a\uff1a\"<\/span>\u00a0+\u00a0result);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5ba2\u6237\u7aef\u4f7f\u7528\u4e5f\u975e\u5e38\u7b80\u5355\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">main<\/span><span style=\"outline: 0px; line-height: 26px;\">(String[]\u00a0args)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5148\u5b9a\u4e49\u4e00\u4e2a\u4e3b\u9898<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0Subject\u00a0subject1\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Subject();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5b9a\u4e49\u89c2\u5bdf\u8005<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0BinaryObserver(subject1);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0HexaObserver(subject1);<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u6a21\u62df\u6570\u636e\u53d8\u66f4\uff0c\u8fd9\u4e2a\u65f6\u5019\uff0c\u89c2\u5bdf\u8005\u4eec\u7684\u00a0update\u00a0\u65b9\u6cd5\u5c06\u4f1a\u88ab\u8c03\u7528<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0subject.setState(<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\">11<\/span>);<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">output:<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\">\u8ba2\u9605\u7684\u6570\u636e\u53d1\u751f\u53d8\u5316\uff0c\u65b0\u7684\u6570\u636e\u5904\u7406\u4e3a\u4e8c\u8fdb\u5236\u503c\u4e3a\uff1a<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\">1011<\/span><br style=\"outline: 0px;\" \/>\u8ba2\u9605\u7684\u6570\u636e\u53d1\u751f\u53d8\u5316\uff0c\u65b0\u7684\u6570\u636e\u5904\u7406\u4e3a\u5341\u516d\u8fdb\u5236\u503c\u4e3a\uff1aB<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5f53\u7136\uff0cjdk \u4e5f\u63d0\u4f9b\u4e86\u76f8\u4f3c\u7684\u652f\u6301\uff0c\u5177\u4f53\u7684\u5927\u5bb6\u53ef\u4ee5\u53c2\u8003 java.util.Observable \u548c java.util.Observer \u8fd9\u4e24\u4e2a\u7c7b\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5b9e\u9645\u751f\u4ea7\u8fc7\u7a0b\u4e2d\uff0c\u89c2\u5bdf\u8005\u6a21\u5f0f\u5f80\u5f80\u7528\u6d88\u606f\u4e2d\u95f4\u4ef6\u6765\u5b9e\u73b0\uff0c\u5982\u679c\u8981\u5b9e\u73b0\u5355\u673a\u89c2\u5bdf\u8005\u6a21\u5f0f\uff0c\u7b14\u8005\u5efa\u8bae\u8bfb\u8005\u4f7f\u7528 Guava \u4e2d\u7684 EventBus\uff0c\u5b83\u6709\u540c\u6b65\u5b9e\u73b0\u4e5f\u6709\u5f02\u6b65\u5b9e\u73b0\uff0c\u672c\u6587\u4e3b\u8981\u4ecb\u7ecd\u8bbe\u8ba1\u6a21\u5f0f\uff0c\u5c31\u4e0d\u5c55\u5f00\u8bf4\u4e86\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8fd8\u6709\uff0c\u5373\u4f7f\u662f\u4e0a\u9762\u7684\u8fd9\u4e2a\u4ee3\u7801\uff0c\u4e5f\u4f1a\u6709\u5f88\u591a\u53d8\u79cd\uff0c\u5927\u5bb6\u53ea\u8981\u8bb0\u4f4f\u6838\u5fc3\u7684\u90e8\u5206\uff0c\u90a3\u5c31\u662f\u4e00\u5b9a\u6709\u4e00\u4e2a\u5730\u65b9\u5b58\u653e\u4e86\u6240\u6709\u7684\u89c2\u5bdf\u8005\uff0c\u7136\u540e\u5728\u4e8b\u4ef6\u53d1\u751f\u7684\u65f6\u5019\uff0c\u904d\u5386\u89c2\u5bdf\u8005\uff0c\u8c03\u7528\u5b83\u4eec\u7684\u56de\u8c03\u51fd\u6570\u3002<\/p>\n<h3 style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><\/h3>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px; border: 0px none initial;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; display: inline-block;\">\n<section style=\"padding-right: 10px; padding-left: 10px; outline: 0px; font-size: 16px; color: #494949;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u8d23\u4efb\u94fe\u6a21\u5f0f<\/span><\/p>\n<\/section>\n<section style=\"margin-top: -10px; outline: 0px; background-color: #fcb42b; height: 8px; color: #ffffff;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">\u8d23\u4efb\u94fe\u901a\u5e38\u9700\u8981\u5148\u5efa\u7acb\u4e00\u4e2a\u5355\u5411\u94fe\u8868\uff0c\u7136\u540e\u8c03\u7528\u65b9\u53ea\u9700\u8981\u8c03\u7528\u5934\u90e8\u8282\u70b9\u5c31\u53ef\u4ee5\u4e86\uff0c\u540e\u9762\u4f1a\u81ea\u52a8\u6d41\u8f6c\u4e0b\u53bb\u3002<\/span><span style=\"outline: 0px; letter-spacing: 0px;\">\u6bd4\u5982\u6d41\u7a0b\u5ba1\u6279\u5c31\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u4f8b\u5b50\uff0c\u53ea\u8981\u7ec8\u7aef\u7528\u6237\u63d0\u4ea4\u7533\u8bf7\uff0c\u6839\u636e\u7533\u8bf7\u7684\u5185\u5bb9\u4fe1\u606f\uff0c\u81ea\u52a8\u5efa\u7acb\u4e00\u6761\u8d23\u4efb\u94fe\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u5f00\u59cb\u6d41\u8f6c\u4e86\u3002<\/span><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6709\u8fd9\u4e48\u4e00\u4e2a\u573a\u666f\uff0c\u7528\u6237\u53c2\u52a0\u4e00\u4e2a\u6d3b\u52a8\u53ef\u4ee5\u9886\u53d6\u5956\u54c1\uff0c\u4f46\u662f\u6d3b\u52a8\u9700\u8981\u8fdb\u884c\u5f88\u591a\u7684\u89c4\u5219\u6821\u9a8c\u7136\u540e\u624d\u80fd\u653e\u884c\uff0c\u6bd4\u5982\u9996\u5148\u9700\u8981\u6821\u9a8c\u7528\u6237\u662f\u5426\u662f\u65b0\u7528\u6237\u3001\u4eca\u65e5\u53c2\u4e0e\u4eba\u6570\u662f\u5426\u6709\u9650\u989d\u3001\u5168\u573a\u53c2\u4e0e\u4eba\u6570\u662f\u5426\u6709\u9650\u989d\u7b49\u7b49\u3002\u8bbe\u5b9a\u7684\u89c4\u5219\u90fd\u901a\u8fc7\u540e\uff0c\u624d\u80fd\u8ba9\u7528\u6237\u9886\u8d70\u5956\u54c1\u3002<\/p>\n<blockquote style=\"margin-top: 20px; margin-bottom: 20px; padding: 10px 10px 10px 20px; outline: 0px; border-left-color: rgba(0, 0, 0, 0.65); color: #6a737d; font-size: 0.9em; border-top: none; border-bottom: none; overflow: auto; border-right: 1px solid rgba(0, 0, 0, 0.65); background: #f9f9f9;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; font-size: 14px; color: black; line-height: 26px;\">\u5982\u679c\u4ea7\u54c1\u7ed9\u4f60\u8fd9\u4e2a\u9700\u6c42\u7684\u8bdd\uff0c\u6211\u60f3\u5927\u90e8\u5206\u4eba\u4e00\u5f00\u59cb\u80af\u5b9a\u60f3\u7684\u5c31\u662f\uff0c\u7528\u4e00\u4e2a List \u6765\u5b58\u653e\u6240\u6709\u7684\u89c4\u5219\uff0c\u7136\u540e foreach \u6267\u884c\u4e00\u4e0b\u6bcf\u4e2a\u89c4\u5219\u5c31\u597d\u4e86\u3002\u4e0d\u8fc7\uff0c\u8bfb\u8005\u4e5f\u5148\u522b\u6025\uff0c\u770b\u770b\u8d23\u4efb\u94fe\u6a21\u5f0f\u548c\u6211\u4eec\u8bf4\u7684\u8fd9\u4e2a\u6709\u4ec0\u4e48\u4e0d\u4e00\u6837\uff1f<\/p>\n<\/blockquote>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u9996\u5148\uff0c\u6211\u4eec\u8981\u5b9a\u4e49\u6d41\u7a0b\u4e0a\u8282\u70b9\u7684\u57fa\u7c7b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">abstract<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">RuleHandler<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u540e\u7ee7\u8282\u70b9<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">protected<\/span>\u00a0RuleHandler\u00a0successor;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">abstract<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">apply<\/span><span style=\"outline: 0px; line-height: 26px;\">(Context\u00a0context)<\/span><\/span>;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">setSuccessor<\/span><span style=\"outline: 0px; line-height: 26px;\">(RuleHandler\u00a0successor)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.successor\u00a0=\u00a0successor;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0RuleHandler\u00a0<span style=\"outline: 0px; line-height: 26px;\">getSuccessor<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0successor;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u9700\u8981\u5b9a\u4e49\u5177\u4f53\u7684\u6bcf\u4e2a\u8282\u70b9\u4e86\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6821\u9a8c\u7528\u6237\u662f\u5426\u662f\u65b0\u7528\u6237\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">NewUserRuleHandler<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">extends<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">RuleHandler<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">apply<\/span><span style=\"outline: 0px; line-height: 26px;\">(Context\u00a0context)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">if<\/span>\u00a0(context.isNewUser())\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5982\u679c\u6709\u540e\u7ee7\u8282\u70b9\u7684\u8bdd\uff0c\u4f20\u9012\u4e0b\u53bb<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">if<\/span>\u00a0(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.getSuccessor()\u00a0!=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">null<\/span>)\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.getSuccessor().apply(context);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">else<\/span>\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">throw<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0RuntimeException(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u8be5\u6d3b\u52a8\u4ec5\u9650\u65b0\u7528\u6237\u53c2\u4e0e\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6821\u9a8c\u7528\u6237\u6240\u5728\u5730\u533a\u662f\u5426\u53ef\u4ee5\u53c2\u4e0e\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">LocationRuleHandler<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">extends<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">RuleHandler<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">apply<\/span><span style=\"outline: 0px; line-height: 26px;\">(Context\u00a0context)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">boolean<\/span>\u00a0allowed\u00a0=\u00a0activityService.isSupportedLocation(context.getLocation);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">if<\/span>\u00a0(allowed)\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">if<\/span>\u00a0(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.getSuccessor()\u00a0!=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">null<\/span>)\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.getSuccessor().apply(context);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">else<\/span>\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">throw<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0RuntimeException(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u975e\u5e38\u62b1\u6b49\uff0c\u60a8\u6240\u5728\u7684\u5730\u533a\u65e0\u6cd5\u53c2\u4e0e\u672c\u6b21\u6d3b\u52a8\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6821\u9a8c\u5956\u54c1\u662f\u5426\u5df2\u9886\u5b8c\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">LimitRuleHandler<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">extends<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">RuleHandler<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">apply<\/span><span style=\"outline: 0px; line-height: 26px;\">(Context\u00a0context)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">int<\/span>\u00a0remainedTimes\u00a0=\u00a0activityService.queryRemainedTimes(context);\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u67e5\u8be2\u5269\u4f59\u5956\u54c1<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">if<\/span>\u00a0(remainedTimes\u00a0&gt;\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\">0<\/span>)\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">if<\/span>\u00a0(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.getSuccessor()\u00a0!=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">null<\/span>)\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.getSuccessor().apply(userInfo);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">else<\/span>\u00a0{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">throw<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0RuntimeException(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u60a8\u6765\u5f97\u592a\u665a\u4e86\uff0c\u5956\u54c1\u88ab\u9886\u5b8c\u4e86\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5ba2\u6237\u7aef\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">main<\/span><span style=\"outline: 0px; line-height: 26px;\">(String[]\u00a0args)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0RuleHandler\u00a0newUserHandler\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0NewUserRuleHandler();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0RuleHandler\u00a0locationHandler\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0LocationRuleHandler();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0RuleHandler\u00a0limitHandler\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0LimitRuleHandler();<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5047\u8bbe\u672c\u6b21\u6d3b\u52a8\u4ec5\u6821\u9a8c\u5730\u533a\u548c\u5956\u54c1\u6570\u91cf\uff0c\u4e0d\u6821\u9a8c\u65b0\u8001\u7528\u6237<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0locationHandler.setSuccessor(limitHandler);<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0locationHandler.apply(context);<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u4ee3\u7801\u5176\u5b9e\u5f88\u7b80\u5355\uff0c\u5c31\u662f\u5148\u5b9a\u4e49\u597d\u4e00\u4e2a\u94fe\u8868\uff0c\u7136\u540e\u5728\u901a\u8fc7\u4efb\u610f\u4e00\u8282\u70b9\u540e\uff0c\u5982\u679c\u6b64\u8282\u70b9\u6709\u540e\u7ee7\u8282\u70b9\uff0c\u90a3\u4e48\u4f20\u9012\u4e0b\u53bb\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u81f3\u4e8e\u5b83\u548c\u6211\u4eec\u524d\u9762\u8bf4\u7684\u7528\u4e00\u4e2a List \u5b58\u653e\u9700\u8981\u6267\u884c\u7684\u89c4\u5219\u7684\u505a\u6cd5\u6709\u4ec0\u4e48\u5f02\u540c\uff0c\u7559\u7ed9\u8bfb\u8005\u81ea\u5df1\u7422\u78e8\u5427\u3002<\/p>\n<h3 style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><\/h3>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px; border: 0px none initial;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; display: inline-block;\">\n<section style=\"padding-right: 10px; padding-left: 10px; outline: 0px; font-size: 16px; color: #494949;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u6a21\u677f\u65b9\u6cd5\u6a21\u5f0f<\/span><\/p>\n<\/section>\n<section style=\"margin-top: -10px; outline: 0px; background-color: #fcb42b; height: 8px; color: #ffffff;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">\u5728\u542b\u6709\u7ee7\u627f\u7ed3\u6784\u7684\u4ee3\u7801\u4e2d\uff0c\u6a21\u677f\u65b9\u6cd5\u6a21\u5f0f\u662f\u975e\u5e38\u5e38\u7528\u7684\u3002<\/span><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u901a\u5e38\u4f1a\u6709\u4e00\u4e2a\u62bd\u8c61\u7c7b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">abstract<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">AbstractTemplate<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u8fd9\u5c31\u662f\u6a21\u677f\u65b9\u6cd5<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">templateMethod<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0init();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0apply();\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u8fd9\u4e2a\u662f\u91cd\u70b9<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0end();\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u53ef\u4ee5\u4f5c\u4e3a\u94a9\u5b50\u65b9\u6cd5<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">protected<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">init<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"init\u00a0\u62bd\u8c61\u5c42\u5df2\u7ecf\u5b9e\u73b0\uff0c\u5b50\u7c7b\u4e5f\u53ef\u4ee5\u9009\u62e9\u8986\u5199\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u7559\u7ed9\u5b50\u7c7b\u5b9e\u73b0<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">protected<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">abstract<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">apply<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span><\/span>;<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">protected<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">end<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6a21\u677f\u65b9\u6cd5\u4e2d\u8c03\u7528\u4e86 3 \u4e2a\u65b9\u6cd5\uff0c\u5176\u4e2d apply() \u662f\u62bd\u8c61\u65b9\u6cd5\uff0c\u5b50\u7c7b\u5fc5\u987b\u5b9e\u73b0\u5b83\uff0c\u5176\u5b9e\u6a21\u677f\u65b9\u6cd5\u4e2d\u6709\u51e0\u4e2a\u62bd\u8c61\u65b9\u6cd5\u5b8c\u5168\u662f\u81ea\u7531\u7684\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u5c06\u4e09\u4e2a\u65b9\u6cd5\u90fd\u8bbe\u7f6e\u4e3a\u62bd\u8c61\u65b9\u6cd5\uff0c\u8ba9\u5b50\u7c7b\u6765\u5b9e\u73b0\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u6a21\u677f\u65b9\u6cd5\u53ea\u8d1f\u8d23\u5b9a\u4e49\u7b2c\u4e00\u6b65\u5e94\u8be5\u8981\u505a\u4ec0\u4e48\uff0c\u7b2c\u4e8c\u6b65\u5e94\u8be5\u505a\u4ec0\u4e48\uff0c\u7b2c\u4e09\u6b65\u5e94\u8be5\u505a\u4ec0\u4e48\uff0c\u81f3\u4e8e\u600e\u4e48\u505a\uff0c\u7531\u5b50\u7c7b\u6765\u5b9e\u73b0\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6211\u4eec\u5199\u4e00\u4e2a\u5b9e\u73b0\u7c7b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">ConcreteTemplate<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">extends<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">AbstractTemplate<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">apply<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u5b50\u7c7b\u5b9e\u73b0\u62bd\u8c61\u65b9\u6cd5\u00a0apply\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">end<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u6211\u4eec\u53ef\u4ee5\u628a\u00a0method3\u00a0\u5f53\u505a\u94a9\u5b50\u65b9\u6cd5\u6765\u4f7f\u7528\uff0c\u9700\u8981\u7684\u65f6\u5019\u8986\u5199\u5c31\u53ef\u4ee5\u4e86\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5ba2\u6237\u7aef\u8c03\u7528\u6f14\u793a\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">main<\/span><span style=\"outline: 0px; line-height: 26px;\">(String[]\u00a0args)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0AbstractTemplate\u00a0t\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0ConcreteTemplate();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u8c03\u7528\u6a21\u677f\u65b9\u6cd5<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0t.templateMethod();<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u4ee3\u7801\u5176\u5b9e\u5f88\u7b80\u5355\uff0c\u57fa\u672c\u4e0a\u770b\u5230\u5c31\u61c2\u4e86\uff0c\u5173\u952e\u662f\u8981\u5b66\u4f1a\u7528\u5230\u81ea\u5df1\u7684\u4ee3\u7801\u4e2d\u3002<\/p>\n<h3 style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><\/h3>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px; border: 0px none initial;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; display: inline-block;\">\n<section style=\"padding-right: 10px; padding-left: 10px; outline: 0px; font-size: 16px; color: #494949;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u72b6\u6001\u6a21\u5f0f<\/span><\/p>\n<\/section>\n<section style=\"margin-top: -10px; outline: 0px; background-color: #fcb42b; height: 8px; color: #ffffff;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">update: 2017-10-19<\/span><\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5e9f\u8bdd\u6211\u5c31\u4e0d\u8bf4\u4e86\uff0c\u6211\u4eec\u8bf4\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u3002\u5546\u54c1\u5e93\u5b58\u4e2d\u5fc3\u6709\u4e2a\u6700\u57fa\u672c\u7684\u9700\u6c42\u662f\u51cf\u5e93\u5b58\u548c\u8865\u5e93\u5b58\uff0c\u6211\u4eec\u770b\u770b\u600e\u4e48\u7528\u72b6\u6001\u6a21\u5f0f\u6765\u5199\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6838\u5fc3\u5728\u4e8e\uff0c\u6211\u4eec\u7684\u5173\u6ce8\u70b9\u4e0d\u518d\u662f Context \u662f\u8be5\u8fdb\u884c\u54ea\u79cd\u64cd\u4f5c\uff0c\u800c\u662f\u5173\u6ce8\u5728\u8fd9\u4e2a Context \u4f1a\u6709\u54ea\u4e9b\u64cd\u4f5c\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5b9a\u4e49\u72b6\u6001\u63a5\u53e3\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">interface<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">State<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">doAction<\/span><span style=\"outline: 0px; line-height: 26px;\">(Context\u00a0context)<\/span><\/span>;<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5b9a\u4e49\u51cf\u5e93\u5b58\u7684\u72b6\u6001\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">DeductState<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">implements<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">State<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">doAction<\/span><span style=\"outline: 0px; line-height: 26px;\">(Context\u00a0context)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u5546\u54c1\u5356\u51fa\uff0c\u51c6\u5907\u51cf\u5e93\u5b58\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0context.setState(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>);<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/...\u00a0\u6267\u884c\u51cf\u5e93\u5b58\u7684\u5177\u4f53\u64cd\u4f5c<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0String\u00a0<span style=\"outline: 0px; line-height: 26px;\">toString<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"Deduct\u00a0State\"<\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5b9a\u4e49\u8865\u5e93\u5b58\u72b6\u6001\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">RevertState<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">implements<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">State<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">doAction<\/span><span style=\"outline: 0px; line-height: 26px;\">(Context\u00a0context)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"\u7ed9\u6b64\u5546\u54c1\u8865\u5e93\u5b58\"<\/span>);<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0context.setState(<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>);<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/...\u00a0\u6267\u884c\u52a0\u5e93\u5b58\u7684\u5177\u4f53\u64cd\u4f5c<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0String\u00a0<span style=\"outline: 0px; line-height: 26px;\">toString<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"Revert\u00a0State\"<\/span>;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u524d\u9762\u7528\u5230\u4e86 context.setState(this)\uff0c\u6211\u4eec\u6765\u770b\u770b\u600e\u4e48\u5b9a\u4e49 Context \u7c7b\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #b8d7a3; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">class<\/span>\u00a0<span style=\"outline: 0px; color: #dcdcdc; line-height: 26px;\">Context<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0State\u00a0state;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">private<\/span>\u00a0String\u00a0name;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">Context<\/span><span style=\"outline: 0px; line-height: 26px;\">(String\u00a0name)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.name\u00a0=\u00a0name;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">setState<\/span><span style=\"outline: 0px; line-height: 26px;\">(State\u00a0state)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.state\u00a0=\u00a0state;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">getState<\/span><span style=\"outline: 0px; line-height: 26px;\">()<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">return<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">this<\/span>.state;<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/>}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6211\u4eec\u6765\u770b\u4e0b\u5ba2\u6237\u7aef\u8c03\u7528\uff0c\u5927\u5bb6\u5c31\u4e00\u6e05\u4e8c\u695a\u4e86\uff1a<\/p>\n<pre style=\"margin-top: 10px; margin-right: auto; margin-left: auto; outline: 0px; box-shadow: rgba(170, 170, 170, 0.48) 0px 0px 6px 0px; border-radius: 4px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 15px 16px 16px; outline: 0px; overflow-x: auto; color: #dcdcdc; display: -webkit-box; font-family: 'Operator Mono', Consolas, Monaco, Menlo, monospace; font-size: 12px; background: #1e1e1e; border-radius: 5px;\"><span style=\"outline: 0px; line-height: 26px;\"><span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">public<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">static<\/span>\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">void<\/span>\u00a0<span style=\"outline: 0px; line-height: 26px;\">main<\/span><span style=\"outline: 0px; line-height: 26px;\">(String[]\u00a0args)<\/span>\u00a0<\/span>{<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u6211\u4eec\u9700\u8981\u64cd\u4f5c\u7684\u662f\u00a0iPhone\u00a0X<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Context\u00a0context\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0Context(<span style=\"outline: 0px; color: #d69d85; line-height: 26px;\">\"iPhone\u00a0X\"<\/span>);<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u770b\u770b\u600e\u4e48\u8fdb\u884c\u8865\u5e93\u5b58\u64cd\u4f5c<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0State\u00a0revertState\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0RevertState();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0revertState.doAction(context);<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u540c\u6837\u7684\uff0c\u51cf\u5e93\u5b58\u64cd\u4f5c\u4e5f\u975e\u5e38\u7b80\u5355<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0State\u00a0deductState\u00a0=\u00a0<span style=\"outline: 0px; color: #569cd6; line-height: 26px;\">new<\/span>\u00a0DeductState();<br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0deductState.doAction(context);<br style=\"outline: 0px;\" \/><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0\u5982\u679c\u9700\u8981\u6211\u4eec\u53ef\u4ee5\u83b7\u53d6\u5f53\u524d\u7684\u72b6\u6001<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"outline: 0px; color: #57a64a; font-style: italic; line-height: 26px;\">\/\/\u00a0context.getState().toString();<\/span><br style=\"outline: 0px;\" \/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<br style=\"outline: 0px;\" \/><\/code><\/pre>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8bfb\u8005\u53ef\u80fd\u4f1a\u53d1\u73b0\uff0c\u5728\u4e0a\u9762\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5982\u679c\u6211\u4eec\u4e0d\u5173\u5fc3\u5f53\u524d context \u5904\u4e8e\u4ec0\u4e48\u72b6\u6001\uff0c\u90a3\u4e48 Context \u5c31\u53ef\u4ee5\u4e0d\u7528\u7ef4\u62a4 state \u5c5e\u6027\u4e86\uff0c\u90a3\u6837\u4ee3\u7801\u4f1a\u7b80\u5355\u5f88\u591a\u3002<\/p>\n<p style=\"padding-top: 8px; padding-bottom: 8px; outline: 0px; line-height: 26px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u4e0d\u8fc7\uff0c\u5546\u54c1\u5e93\u5b58\u8fd9\u4e2a\u4f8b\u5b50\u6bd5\u7adf\u53ea\u662f\u4e2a\u4f8b\uff0c\u6211\u4eec\u8fd8\u6709\u5f88\u591a\u5b9e\u4f8b\u662f\u9700\u8981\u77e5\u9053\u5f53\u524d context \u5904\u4e8e\u4ec0\u4e48\u72b6\u6001\u7684\u3002<\/p>\n<h3 style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><\/h3>\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-mpa-template=\"t\">\n<section style=\"outline: 0px;\" data-color=\"rgb(252, 180, 43)\">\n<section style=\"outline: 0px; border: 0px none initial;\">\n<section style=\"outline: 0px;\">\n<section style=\"outline: 0px; display: inline-block;\">\n<section style=\"padding-right: 10px; padding-left: 10px; outline: 0px; font-size: 16px; color: #494949;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 18px;\">\u884c\u4e3a\u578b\u6a21\u5f0f\u603b\u7ed3<\/span><\/p>\n<\/section>\n<section style=\"margin-top: -10px; outline: 0px; background-color: #fcb42b; height: 8px; color: #ffffff;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; letter-spacing: 0px;\">\u884c\u4e3a\u578b\u6a21\u5f0f\u90e8\u5206\u4ecb\u7ecd\u4e86\u7b56\u7565\u6a21\u5f0f\u3001\u89c2\u5bdf\u8005\u6a21\u5f0f\u3001\u8d23\u4efb\u94fe\u6a21\u5f0f\u3001\u6a21\u677f\u65b9\u6cd5\u6a21\u5f0f\u548c\u72b6\u6001\u6a21\u5f0f\uff0c\u5176\u5b9e\uff0c\u7ecf\u5178\u7684\u884c\u4e3a\u578b\u6a21\u5f0f\u8fd8\u5305\u62ec\u5907\u5fd8\u5f55\u6a21\u5f0f\u3001\u547d\u4ee4\u6a21\u5f0f\u7b49\uff0c\u4f46\u662f\u5b83\u4eec\u7684\u4f7f\u7528\u573a\u666f\u6bd4\u8f83\u6709\u9650\uff0c\u800c\u4e14\u672c\u6587\u7bc7\u5e45\u4e5f\u633a\u5927\u4e86\uff0c\u6211\u5c31\u4e0d\u8fdb\u884c\u4ecb\u7ecd\u4e86\u3002<\/span><\/p>\n<p style=\"outline: 0px;\">\n<blockquote class=\"js_blockquote_wrap\" style=\"outline: 0px; color: var(--weui-fg-1);\" data-type=\"2\" data-url=\"\" data-author-name=\"\" data-content-utf8-length=\"43\" data-source-title=\"\">\n<section class=\"js_blockquote_digest\" style=\"outline: 0px;\">\n<section style=\"outline: 0px;\">\n<p style=\"outline: 0px;\"><span style=\"outline: 0px; font-size: 11px;\">\u6765\u6e90\uff1ahttps:\/\/javadoop.com\/post\/design-pattern<\/span><\/p>\n<\/section>\n<\/section>\n<\/blockquote>\n<\/section>\n<p style=\"text-align: center; margin-bottom: 0px;\"><img decoding=\"async\" class=\"rich_pages wxw-img js_insertlocalimg lazyload\" style=\"width: 100%; height: auto;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005444274.gif\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\" data-backh=\"113\" data-backw=\"578\" data-ratio=\"0.1949685534591195\" data-s=\"300,640\" data-type=\"gif\" data-w=\"636\" \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img js_insertlocalimg\" style=\"width: 100%; height: auto;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005444274.gif\" data-backh=\"113\" data-backw=\"578\" data-ratio=\"0.1949685534591195\" data-s=\"300,640\" data-type=\"gif\" data-w=\"636\" \/><\/noscript><\/p>\n<p style=\"outline: 0px; max-width: 100%; color: #222222; font-variant-numeric: normal; font-variant-east-asian: normal; font-stretch: normal; font-size: 12px; line-height: 2em; font-family: -apple-system, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; white-space: normal; background-color: #ffffff; text-align: right; vertical-align: inherit; widows: 1; margin-bottom: 0px; box-sizing: border-box !important; overflow-wrap: break-word !important;\">\n<p style=\"display: none;\">\n<blockquote><p>\u672c\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8e\u5fae\u4fe1\u516c\u4f17\u53f7: BUG\u5f04\u6f6e\u513f<\/p><\/blockquote>\n<\/div>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>\u76ee\u5f55 \u521b\u5efa\u578b\u6a21\u5f0f \u7ed3\u6784\u578b\u6a21\u5f0f \u884c\u4e3a\u578b\u6a21\u5f0f \u603b\u7ed3 \u524d\u8a00 \u4e00\u76f4\u60f3\u5199\u4e00\u7bc7\u4ecb\u7ecd\u8bbe\u8ba1\u6a21\u5f0f\u7684\u6587\u7ae0\uff0c\u8ba9\u8bfb\u8005\u53ef\u4ee5\u5f88\u5feb\u770b\u5b8c\uff0c\u800c\u4e14\u4e00\u770b\u5c31\u61c2\uff0c\u770b\u61c2\u5c31\u4f1a\u7528 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":394,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[2],"tags":[],"class_list":["post-411","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005348265-150x150.jpeg","content_first_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005349628.gif","post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005348265-300x127.jpeg","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005348265.jpeg","post_frist_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005349628.gif","post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005348265-300x127.jpeg","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005348265.jpeg","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005348265.jpeg","post_all_images":[{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005349628.gif","id":"image0"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005349628.gif","id":"image1"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005350226.png","id":"image2"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005350226.png","id":"image3"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005353211.png","id":"image4"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005353211.png","id":"image5"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005357327.png","id":"image6"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005357327.png","id":"image7"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005359799.png","id":"image8"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005359799.png","id":"image9"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005403768.png","id":"image10"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005403768.png","id":"image11"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005406171.png","id":"image12"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005406171.png","id":"image13"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005410415.png","id":"image14"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005410415.png","id":"image15"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005413805.png","id":"image16"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005413805.png","id":"image17"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005418303.png","id":"image18"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005418303.png","id":"image19"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005423439.png","id":"image20"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005423439.png","id":"image21"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005427972.png","id":"image22"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005427972.png","id":"image23"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005432976.png","id":"image24"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005432976.png","id":"image25"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005435525.png","id":"image26"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005435525.png","id":"image27"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005439332.png","id":"image28"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005439332.png","id":"image29"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005444274.gif","id":"image30"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528005444274.gif","id":"image31"}],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"Java","post_date":"2023-05-27","like_count":"0","praiseWord":"\u9f13\u52b1","copyright_state":"","excitationAd":"0","rewardedVideoAdId":"","detailAdId":"","detailAd":"0","enterpriseMinapp":"0","audios":[],"postImageUrl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230519082947553.jpg","avatarurls":[],"related_posts":null,"pageviews":305,"next_post_id":688,"next_post_title":"JAVA \u7ebf\u4e0a\u6545\u969c\u6392\u67e5\u5b8c\u6574\u5957\u8def\uff0c\u4ece CPU\u3001\u78c1\u76d8\u3001\u5185\u5b58\u3001\u7f51\u7edc\u3001GC \u4e00\u6761\u9f99\uff01","previous_post_id":375,"previous_post_title":"\u53cd\u5c04\u4e0e\u81ea\u5b9a\u4e49\u6ce8\u89e3","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/comments?post=411"}],"version-history":[{"count":0,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/411\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media\/394"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}