package com.lianxi; //抄作业要改名,改com.liaanxi就行了 class father{ public void chongwu(){ System.out.println("宠物有很多种类"); } } class sun extends father{ public void chongwu(){ System.out.println("猫是宠物"); } } class sun1 extends father{ public void chongwu() { System.out.println("狗也是宠物"); } } public class 007 { //抄作业要改名,改007就行了 public static void main(String[] args){ father l1=new father(); father l2=new sun(); father l3=new sun1(); l1.chongwu(); l2.chongwu(); l3.chongwu(); } }
多态的用法、多态的表达形式——例题
最新推荐文章于 2024-11-03 11:01:20 发布