Alex Rivera | Logout

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

Asked 2011-08-16T10:53:29.167
21

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> {
    ...
}
Edit
Report

1 Answer

32
public class Clazz<T extends Serializable> {
    ...
}
answered 2011-08-16T10:55:47.990

Your Answer