Jatin
Jatin

Reputation: 31724

List and Generics

I have an interface below:

/**
 * <T> Time format. Can be long, date etc
 */
public interface TimeStamp<T> extends Comparable<TimeStamp<T>>
{
/**
 * Returns the timestamp. 
 * @return 
 */
public T getTimeStamp();
}

Now I want to have a list, that will hold TimeStamp and have some methods whose behavior will depend upon the timeStamps it holds.

public class TimeList<TimeStamp<T>> extends ArrayList<TimeStamp<T>> 
{
     ......
}

The compiler shows error with the above statement. What is wrong with it?

Upvotes: 0

Views: 75

Answers (1)

koljaTM
koljaTM

Reputation: 10262

In the class definition you can only specify the generic type alone, try:

public class TimeList<T> extends ArrayList<TimeStamp<T>> 
{
 ......
}

Upvotes: 9

Related Questions