[求助]编译时提示找不到方法
class Shoes{
void walk(Shoes shoes){ //行走
if (shoes instanceof Leather){
shoes=(Leather)shoes;
shoes.land();
System.out.println("111");
}
if(shoes instanceof Sandal){
//shoes=(Sandal)shoes;
//shoes.water();
System.out.println("2222");
}
}
}
class Leather extends Shoes{ //皮鞋
void land(){
System.out.println("我可以在陆地行走.");
}
}
class Sandal extends Shoes{ //凉鞋
void water(){
System.out.println("我可以在水中行走.");
}
}
class ShoesTest{
public static void main(String[] args){
Shoes shoes=new Shoes();
Leather l=new Leather();
Sandal s=new Sandal();
shoes.walk(l);
shoes.walk(s);
}
}
编译时提示找不到land方法?
怎么回事?