开发者

Java generics - is it possible to restrict T to be Serializable?

Is it possible to make something like this? I know that implements cannot be in the <>, but I want to restrict the T to be Serializable somehow.

public class Clazz<开发者_运维知识库;T implements Serializable> {
    ...
}


public class Clazz<T extends Serializable> {
    ...
}


Just use extends instead of implements.


Yes, just use extends instead of implements.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜