Suppose I an abstract class defined like this:
public class Response<T> { private List<Response<T>> subResponses; } and two subclasses defined like this:
public class SectionResponse extends Response<SectionResponse> { } public class FormResponse extends Response<FormResponse> { } Basically all subclasses of Response need to have a list of the same class. Now somewhere else in the code I want to have a list of Response objects that can contain either subclass.
What would be the best way to define this list without using raw types? I've tried List<? extends Response<?>> but I can't call the add method on a List defined like this because the parameter is a parameterized type.
List<T extends Response<T>>? Just thinking aloud.