I have a class called Contact, which is the superclass of classes named PersonalContact and BusinessContact.
I have one abstract method in my class which is supposed to tell the subclasses to implement it. The method is
public abstract Set<T> getEventsWithinPeriod(DateTime start, DateTime end);
The T is there to be interchanged with the different type of events in each subclass. PersonalContacts have birthdays, and BusinessContacts have meetings.
The problem is I am getting an error saying T cannot be resolved to a type, but isn’t that the whole point of generics?
I tried putting the in the class header as well
public abstract class Contact<T> implements Comparable<Contact>{
but the compiler gives me a warning saying
Contact is a raw type. References to generic type Contact<T> should be parameterized.
How do I fix this?
Since you want to tie T with the subclass instead of getEventsWithinPeriod method, declare T as parameter for contact.