首页 > 编程知识 正文

java返回泛型的方法,java 泛型擦除

时间:2023-05-03 05:29:08 阅读:11256 作者:4521

I have接口:

public接口牢固的手套extends brdhj{

技术(动作动作);

}

I wish override ' execute ' methodinimplementation :

公共课堂xx实施的坚强手套{

@Override

publicgetcartresponseexecute (getcartaction ) {

//todo自动- generated method stub

返回空值;

}

}

But receive compiler error:

themethodexecute (获取卡片) oftypexxmustoverrideorimplementasupertypemethod

GetCart GetCartResponse:

publicclassgetcartimplementsaction {

}

publicclassgetcartresponseimplementsgsddx {

私有金融阵列项目;

publicgetcartresponse{

this.items=items;

}

公共阵列设置() )。

返回项;

}

}

How can I override this method?

theproblemisthedefinitionoftheinterfacevswhattheerausreshouldlooklikeforyourimpl.inyourexampleyouhave 3360

技术(动作动作);

publicgetcartresponseexecute (获取功能;

butaccordingtotheinterfacedefinitiontheimplementationmethodshouldread :

公共攻击响应执行(动作动作;

soithinkyoueitherneedtochangethesignatureofyourinterfaceoraddanothertypeparametersuchas :

public接口牢固的手套extends brdhj{

技术(u动作);

}

orpossiblysomethingalongthelinesof :

public接口牢固的手套extends brdhj{

gsddxexecute (动作动作;

}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。