{"id":219294,"date":"2021-06-12T08:13:39","date_gmt":"2021-06-12T00:13:39","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=219294"},"modified":"2021-05-24T09:14:35","modified_gmt":"2021-05-24T01:14:35","slug":"java-upward-transformation","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/java-upward-transformation.html","title":{"rendered":"java\u591a\u6001\u7684\u5411\u4e0a\u8f6c\u578b"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | \u5728\u672c\u7bc7\u5185\u5bb9\u91cc\u5c0f\u7f16\u7ed9\u5927\u5bb6\u6574\u7406\u7684\u662f\u4e00\u7bc7\u5173\u4e8ejava\u591a\u6001\u7684\u5411\u4e0a\u8f6c\u578b\u7684\u6982\u5ff5\u53ca\u5b9e\u4f8b\u5206\u6790\uff0c\u5bf9\u6b64\u6709\u5174\u8da3\u7684\u670b\u53cb\u4eec\u53ef\u4ee5\u8ddf\u7740\u5b66\u4e60\u4e0b\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n 1\u3001\u8bf4\u660e<\/strong><\/span><\/div>\n \u5411\u4e0a\u8f6c\u578b\u5c31\u662f\u628a\u4e00\u4e2a\u5b50\u7c7b\u5f15\u7528\u7ed9\u4e00\u4e2a\u7236\u7c7b\u5f15\u7528\uff0c\u4e5f\u5c31\u662f\u7236\u7c7b\u5f15\u7528 \u5f15\u7528\u4e86\u5b50\u7c7b\u7684\u5bf9\u8c61\uff0c\u5373\u7236\u7c7b \u7236\u7c7b\u5bf9\u8c61 = \u5b50\u7c7b\u5b9e\u4f8b\u3002<\/p>\n \u6b64\u65f6\u901a\u8fc7\u7236\u7c7b\u5f15\u7528\u53d8\u91cf\u8c03\u7528\u7684\u65b9\u6cd5\u662f\u5b50\u7c7b\u8986\u76d6\u6216\u7ee7\u627f\u7236\u7c7b\u7684\u65b9\u6cd5\uff0c\u800c\u4e0d\u662f\u7236\u7c7b\u7684\u65b9\u6cd5\u3002\u4f46\u662f\u8c03\u7528\u7684\u5c5e\u6027\u8fd8\u662f\u7236\u7c7b\u7684\u5c5e\u6027\u3002<\/p>\n 2\u3001\u5b9e\u4f8b<\/strong><\/span><\/div>\n \r\nclass Animal {\r\n public String name;\r\n public void eat() {\r\n System.out.println(this.name + \" \u6b63\u5728\u5403\");\r\n }\r\n}\r\nclass Cat extends Animal {\r\n \r\n}\r\npublic class Test extends TestDemo {\r\n \r\n public static void main(String[] args) {\r\n \/\/\u7236\u7c7b\u5f15\u7528 \u5f15\u7528\u4e86 \u5b50\u7c7b\u5f15\u7528\u6240\u5f15\u7528\u7684\u5bf9\u8c61\r\n Cat cat = new Cat();\r\n Animal animal = cat;\/\/\u5411\u4e0a\u8f6c\u578b\r\n }\r\n}\r\n<\/pre>\n |