Java 过度驾驶方法赢得';t转换

Java 过度驾驶方法赢得';t转换,java,inheritance,methods,polymorphism,overriding,Java,Inheritance,Methods,Polymorphism,Overriding,我得到这段代码是为了生成一个运行程序文件,我不知道如何在Proj05 runner类中定义我的方法,以便在声明obj为新的Proj05Runner()后打印字符串之前打印语句 这就是我到目前为止所做的: class Proj05Runner{ static String run(){ System.out.println("I certify that this program is my own work\n" + "and

我得到这段代码是为了生成一个运行程序文件,我不知道如何在Proj05 runner类中定义我的方法,以便在声明obj为新的Proj05Runner()后打印字符串之前打印语句

这就是我到目前为止所做的:

class Proj05Runner{
    static String run(){
        System.out.println("I certify that this program is my own work\n" +
        "and is not the work of others. I agree not\n" +
        "to share my solution with others.\n" +
        "Brendan Pitcher");
    }
}
但当我运行Proj05时,我被告知:

> Proj05.java:16: error: incompatible types: Proj05Runner cannot be
> converted to Proj05
>     Proj05 obj = new Proj05Runner();
>                  ^ 1 error
我的预期输出应该如下所示:

I certify that this program is my own work
and is not the work of others. I agree not
to share my solution with others.
==========================
Call the method named run.
Replace this line with your name
编辑: 我已在Proj05Runner中扩展了Proj05,并在Proj05Runner中将方法更改为void run()。因此,程序正在运行,但显示:

==========================
Call the method named run.
I certify that this program is my own work
and is not the work of others. I agree not
to share my solution with others.
Brendan Pitcher
Hello World
Press any key to continue . . .

因为我仍然不确定如何首先打印认证文本。

看起来Proj05Runner应该扩展Proj05。根据代码中的注释,为什么要将Proj05Runner上的run()方法设置为静态的?(考虑继承)
Proj05Runner
不继承。@tgdavies我扩展了它,现在它正在运行,但我确定如何在:System.out.println(“=============================================”)之前运行“打印入”;println(“调用名为run的方法”);这种方法不能是静态的。它需要重写基类中的
run()
方法。很抱歉,我已经将其更改为void以匹配main中的原始run(),但我不理解在开始打印并调用run、将obj重新声明为Proj05并再次调用run之前,声明Proj05Runner类型的对象应该如何生成文本
==========================
Call the method named run.
I certify that this program is my own work
and is not the work of others. I agree not
to share my solution with others.
Brendan Pitcher
Hello World
Press any key to continue . . .