首页 > 代码库 > 接口的实现

接口的实现

interface Jiao{ void jiaosheng();}
class gou implements Jiao{
public void jiaosheng(){
System.out.println("狗的叫声是:汪汪。");
}
}
class mao implements Jiao{
public void jiaosheng(){
System.out.println("猫的叫声是:喵喵。");
}
}
class yang implements Jiao{
public void jiaosheng(){
System.out.println("羊的叫声是:咩咩。");
}
}
public class Ex5_13 {
public static void main(String[] args){
new gou().jiaosheng();
new mao().jiaosheng();
new yang().jiaosheng();
}
}

技术分享

 

接口的实现