//Package in which I have both the Parent and the Child class
package learningJava;
public class MainMethodDemoParent
{
//Main method of the parent class
public static void main(String... args)
{
System.out.print("This is the Parent class");
}
}
//Child class which extends the Parent class
package learningJava;
public class MainMethodDemoChild extends MainMethodDemoParent
{
}
当我尝试运行没有 main 方法但与父类位于同一包中的子类以便我可以访问父类的 main 方法时,在 Eclipse 中没有 RUN 选项Child类是一个java应用程序。
最佳答案
我通过在 eclipse 中这样做解决了这个问题: 步骤 1 右键单击 --> 运行配置
第2步选中复选框-搜索主类时包含继承的主类。
第 3 步 - 现在再次点击“搜索”。您应该能够找到您要查找的子类。
关于java - 在 Eclipse 中运行一个 CHILD,其中 PARENT 类具有 main 方法,但 CHILD 类本身只是一个没有 main 方法的类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61806162/