首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Java关于@Override

Java关于@Override
EN

Stack Overflow用户
提问于 2014-07-11 04:53:27
回答 3查看 132关注 0票数 1

那么覆盖的问题是什么呢?我不明白:

代码语言:javascript
复制
@Override
public ProtocolEncoder getEncoder(IoSession session) throws Exception {
    return encoder;
}
@Override
public ProtocolDecoder getDecoder(IoSession session) throws Exception {
    return decoder;
}

错误:

代码语言:javascript
复制
error: method does not override or implement a method from a supertype
@Override

error: MaplePacketDecoder is not abstract and does not override abstract method doDecode(IoSession,ByteBuffer,ProtocolDecoderOutput) in CumulativeProtocolDecoder
public class MaplePacketDecoder extends CumulativeProtocolDecoder {

error: method write in interface ProtocolEncoderOutput cannot be applied to given types;
                out.write(IoBuffer.wrap(ret));
  required: ByteBuffer
  found: IoBuffer
  reason: actual argument IoBuffer cannot be converted to ByteBuffer by method invocation conversion
EN

回答 3

Stack Overflow用户

发布于 2014-07-11 04:56:16

您忘记了实现doDecode(IoSession,ByteBuffer,ProtocolDecoderOutput)

票数 2
EN

Stack Overflow用户

发布于 2014-07-11 05:08:42

您正试图用不同的参数(不同的签名)覆盖超类中的方法。重写方法必须匹配被重写的方法的签名(在父类中)。

http://docs.oracle.com/javase/tutorial/java/IandI/override.html

票数 1
EN

Stack Overflow用户

发布于 2014-07-11 05:04:55

您尝试重写的方法名称或您提供的参数似乎不正确。此外,您也不能从CumulativeProtocolDecoder实现doDecode方法。如果CumulativeProtocolDecoder是一个抽象类,那么你应该实现它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24686091

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档