Crow_Null 2015-12-18 11:33 采纳率: 100%
浏览 4440
已采纳

JAVA 实现接口方法时报错 implement a supertype method

public interface MultimediaControl {
public void play();
public void stop();
public void previous();
public void next();
}

public class AudioPlayer extends Product implements MultimediaControl {
String audioSpecification;
ItemType mediaType;

@Override //The method play() of type AudioPlayer must override or 
 implement a supertype method
public void play() {
    System.out.println("Playing");
}

@Override //The method stop() of type AudioPlayer must override or 
 implement a supertype method
public void stop() {
    System.out.println("Stopped");
}

@Override //The method previous() of type AudioPlayer must override or 
 implement a supertype method
public void previous() {
    System.out.println("To the previous");
}

@Override
public void next() //The method next() of type AudioPlayer must override or 
 implement a supertype method{
    System.out.println("To the Next");
}

public AudioPlayer(String name, ItemType Type) {
    super(name); //The constructor Product(String) is undefined
    mediaType = Type;
}

}

还有构造函数中调用父类带参构造函数, 父类中的构造函数 :
public Product(String Name) {
name = Name;
serialNumber = currentProductionNumber;
manufacturedOn = new Date();
}
明明有带String参数的构造?为什么会提示这些错误呢

  • 写回答

2条回答 默认 最新

  • 毕小宝 领域专家: 后端开发技术领域 2015-12-18 11:46
    关注

    我测试过了,没有问题啊,你是用Eclipse自动提示完成实现接口方法的吗?
    先定义类实现接口后,使用Eclipse自动提示ctrl+1,选择实现接口方法,就能自动生成方法了。
    图片说明
    没有问题的,你可以重新生成下代码,或者保存下文件。
    父类构造函数调用没有问题的。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?