为什么在课堂上找不到主要的方法? [英] why is the main method is not found in the class?
本文介绍了为什么在课堂上找不到主要的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
class AB {
public void dog(){
System.out。的println( 狗);
}
}
class C extends AB {
public void cat(){
System.out.println(Cat);
}
}
class ABC {
public static void main(String [] args){
AB obj1 = new AB();
C obj2 = new C();
AB obj3 = new C();
obj1.dog();
obj2.cat();
obj2.dog();
obj3.dog();
//obj3.cat();
}
}
当我从Eclipse运行时,它是没有从运行方式显示java应用程序。
解决方案
转到运行配置 - > java应用程序,然后选择你的课程 ABC
并运行它。
I made a simple Java program, but it shows that main method is not found in the class. But it is there:
class AB {
public void dog() {
System.out.println("Dog");
}
}
class C extends AB {
public void cat() {
System.out.println("Cat");
}
}
class ABC {
public static void main(String[] args) {
AB obj1 = new AB();
C obj2 = new C();
AB obj3 = new C();
obj1.dog();
obj2.cat();
obj2.dog();
obj3.dog();
//obj3.cat();
}
}
Also when I am running from the Eclipse, it is not showing java application from the Run As.
解决方案
Go to run configuration --> java application then select your class ABC
and Run it.
这篇关于为什么在课堂上找不到主要的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文