- class lianxi
- {
- public static void main(String[] args)
- {
-
- fangfa1(new mao());
- fangfa1(new gou());
-
- }
- public static void fangfa1(dongwu a)
- {
- a.chi();
- }
- }
- abstract class dongwu
- {
- abstract void chi();
- }
- class mao extends dongwu
- {
- public void chi()
- {
- System.out.println("mao");
- }
- }
- class gou extends dongwu
- {
- public void chi()
- {
- System.out.println("gou");
- }
- }
复制代码 |
|