我知道很多人问这样的问题,但我真的没有得到这个。Java泛型编译错误 - 不明白错误
(如果你需要更多的代码,请告诉)
public class QuestionManager<Question extends Component & IQuestion<? extends IAnswerStorage>>
public class AccountingQuestionManager<Question extends Component & IQuestion<? extends IAnswerStorage>> extends QuestionManager<Question>
public interface IQuestion<DataStorage extends IAnswerStorage>
IAnswerStorage
是一个空的接口
这是我3泛型类,我需要解释。在QuestionManager
问题需要问题(IQuestions
)[与指定存储]
我现在尝试以下,希望它允许任何问题,这也是组件。
QuestionManager<? extends Component & IQuestion<? extends IAnswerStorage>> manager = new AccountingQuestionManager<>(
"Test test", this);
我也有一个功能问题增加的问题,池:
manager.addQuestion(question);
,但我得到了2个以下错误:
Incorrect number of arguments for type QuestionManager<Question>; it cannot be parameterized with arguments <? extends Component, IQuestion<? extends IAnswerStorage>>
Syntax error on token "&", , expected
太感谢很多为你的帮助。让我知道你是否需要更多。
你可以使用'&'http://docs.oracle.com/javase/tutorial/java/generics/bounded.html – FazoM 2014-09-19 15:18:51
哦,我的坏。我会修改答案 – SirRichie 2014-09-19 15:19:56
自'QuestionManager'何时有两个类型参数? – bcsb1001 2014-09-19 15:24:16