test9.1
来源:互联网 发布:mysql minute函数 编辑:程序博客网 时间:2024/06/09 05:39
把Rodent 编程一个抽象类,内部的方法也变成抽象方法
abstract class Rodent{
public abstract void apperence();
}
class Mouse extends Rodent{
public void apperence(){System.out.println("It runs fast");}
}
class Hamster extends Rodent{
public void apperence(){System.out.println("It's so big");}
}
class Gerbil extends Rodent{
public void apperence(){System.out.println("It's eyes are small");}
}
public class Test1 {
public static void main(String[] args) {
Rodent[] r={new Mouse(),new Gerbil(),new Hamster()};
for(Rodent i:r)
i.apperence();
}
}
//the output shows r[0,1,2] operate its own apperence().
0 0
- test9.1
- test9-1(类三角形)
- test9
- test9
- test9.3
- test9.4
- test9.5
- test9.7
- test9.8
- test9.9
- test9.10
- test9.12
- test9.13
- test9.14
- test9.15
- test9.16
- test9.17
- test9.18
- CocosPods安装和使用教程
- H字首类破解补丁速查
- [译]How browsers work
- G字首类破解补丁速查
- F字首类破解补丁速查
- test9.1
- iOS开发之时间格式的转化
- A字首类破解补丁速查
- 利用iptables为gearman增加访问规则
- 英雄展示代码进一步完善(包括可重用单元格)
- 测试bug级别定义
- Struts2返回JSON对象的方法总结
- Jungle Roads
- linux下用gtk+写比赛赌博GUI小游戏