class Fu
{
void show()
{
System.out.println("fu show");
}
void speak(int a)
{
System.out.println("vb");
}
}
class Zi extends Fu
{
void speak(String b)
{
System.out.println("java");
}
void show()
{
System.out.println("zi show");
}
}
class ExtendsDemo
{
public static void main(String[] args)
{
Zi z = new Zi();
z.speak("a");
z.speak(1);
}
}
//子父类中函数同名,但是参数列表不同,会根据传递的参数选择调用子类的方法还是父类的方法 |
|