首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

java- 种之间的继承

2012-11-22 
java---- 类之间的继承text.javapublic class text {public static void main(String args[]) {fatty fne

java---- 类之间的继承

text.java

public class text {public static void main(String args[]) {fatty f=new fatty();food fo=new food();food po=new potpie();f.digest(fo);f.digest(po);}}

potpie.java

public class potpie extends food{void eat(){System.out.println("this potpie is great");}}

tune.java

public class tune {void eat(){System.out.println("this tune is great");}}

food.java

public class food {void eat(){System.out.println("this food is great");}}


 

fatty.java

public class fatty {public void digest(food x){x.eat();}}


 

热点排行