I am tired of the below issue. please help? I have a below interface
/**
* <T> Type of Timestamp. For ex: Date, long, Calendar etc
*
*/
public interface TimeStamp<T> extends Comparable<TimeStamp<T>>
{
/**
* Returns the timestamp.
* @return
*/
public T getTimeStamp();
}
And in my code I have 2 lists:
List<FileTimeStamp> f = new ArrayList<FileTimeStamp>();
List<DefaultTimeStamp> t = new ArrayList<DefaultTimeStamp>();
I want to create a method that takes the above 2 lists containing TimeStamps and then merge them. Ex:
void merge(List<TimeStamp> l1, List<TimeStamp> l2)
{
l1.addAll(l2);
Collections.sort(l1);
}
But the above generates compile time warnings.
void merge(List l1, List l2)
missing type arguments for generic class TimeStamp
where T is a type-variable: T extends Object declared in interface TimeStamp
How should I define the above method without any compile time warnings? What should be my void merge(List<TimeStamp<????>> l1, List<TimeStamp<????>> l2)
???? in left be?