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
.
精彩评论