package com.study.exception.demo09;
public class Cat {
public void eat(){
System.out.println("猫吃鱼");
}
}
package com.study.exception.demo09;
public class CatOperate {
public void useCat(Cat c){
c.eat();
}
public Cat getCat(){
Cat c = new Cat();
return c;
}
}
package com.study.exception.demo09;
public class CatDemo {
//方法的形参是类名,其实需要的是该类的对象
//方法的返回值是类名,其实返回的是该类的对象
public static void main(String[] args) {
CatOperate d = new CatOperate();
Cat c = new Cat();
d.useCat(c);
Cat c2 = d.getCat();
c2.eat();
}
}
package com.study.exception.demo09;public class Cat { public void eat(){ System.out.println("猫吃鱼"); }}package com.study.exception.demo09;public class CatOperate { public void useCat(Cat c){ c.eat(); } public Ca