Given the following java code:
public static <I extends Serializable, L extends List<I> & Serializable> L getList() {
return new ArrayList<I>(); // <-- Compile error
}
Given that ArrayList do extend both Serializable and List, why does it produce a compile error?
Incompatible types. Found: 'java.util.ArrayList<I>', required: 'L'
I came up with this solution:
Then whenever I need a
SerializableListtype, I can use theSerializableListinterface and its implementationSerializableArrayList