我们今天早上在java中讨论了继承问题,但是好像我的代码有错误,我的教授无法帮助我,因为他很忙,你能帮我指点我的错误吗?继承java“找不到符号”
package inheritance;
class Inheritance {
void accelerate()
{
System.out.println("Drive");
}
void turn()
{
System.out.println("Turn!");
}
}
class n2wheels extends Inheritance {
void fast()
{
System.out.println("Swift Vehicle");
}
}
class n4wheels extends Inheritance {
void normal()
{
System.out.println("Average Vehicle");
}
}
class multiwheel extends Inheritance {
void slow()
{
System.out.println("Heavy Vehicle");
}
public static void main(String[] args)
{
Inheritance try1 = new Inheritance();
try1.normal();
}
}
您没有一个名为'no rmal'在你的类中称为'Inheritance'。 –
'normal'不是继承的方法。 – luk2302
只是一个提示:关于Java中的继承有很多解释。看看这些并试图了解它的含义以及它的工作原理。否则,你将来会遇到很多问题,因为你显然错误理解了那里的某些东西。祝你好运! – Luftbaum