我不知道问题是什么,它给出了:“返回类型 void 与字符串接口 java 不兼容”,我读了一些关于相同方法签名的东西,但不明白。我该如何解决这个问题或向哪个方向挖掘。
public class Student implements Printable {
Student() {
...
}
public void doing() {
System.out.printf(" что то делает ");
}
}
class StudentDetails extends Student implements Printable {
StudentDetails() {
super()
...
}
public void doing(){
System.out.println("делает что то вдобавок");
}
}
interface Printable {
void doing();
}
class Main {
public static void main(String[] arg) {
Student st1 = new Student();
Student st2 = new Student();
Student st3 = new Student();
Student st4 = new Student();
Student st5 = new Student();
Student[] students = new Student[5];
students[0] = st1;
students[1] = st2;
students[2] = st3;
students[3] = st4;
students[4] = st5;
for (int i = 0; i < students.length; i++) {
System.out.println(students[i].doing());
}
}
}
System.out.println
期望您将字符串作为参数传递,并且该方法doing
不返回任何内容,因为它void
是 .尝试