少了部分,按错键了发了- abstract class Animal{
- abstract void chi();
- class XinZang{
- void tiaoDong(){
- System.out.println("心脏在跳动");
- }
- }
- }
- class Car extends Animal{
- @Override
- void chi() {
- System.out.println("吃鱼");
- }
- XinZang x = new XinZang();
- x.tiaoDong();//编译出错,怎么调用内部类的方法
- }
- class Dog extends Animal{
- @Override
- void chi() {
- System.out.println("吃骨头");
- }
- }
复制代码
|