本帖最后由 徐卓 于 2013-7-15 10:15 编辑
- <div class="blockcode"><blockquote>abstract class animal
- {
- public abstract String eat();
- }
- class cat extends animal
- {
- public String eat()
- {
- return "吃东西";
- }
- public String catching()
- {
- return "抓老鼠";
- }
- }
- class Demo
- {
- public static void main(String[] args)
- {
- animal a=new cat();
- System.out.println(a.eat());
- //我希望System.out.println(a.catching());成立,当是不能改变animal a=new cat()为cat a=new cat();
- }
- }
复制代码 求解答,怎样才能让猫抓老鼠
|