且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么在课堂上找不到主要的方法?

更新时间:2023-11-18 15:14:58

转到运行配置 - > 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