为什么在课堂上找不到主要的方法? [英] why is the main method is not found in the class?

查看:79
本文介绍了为什么在课堂上找不到主要的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个简单的Java程序,但是它显示了在类中没有找到main方法。但是它在那里:

  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.

Check Here

这篇关于为什么在课堂上找不到主要的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆