I would like to have a PriorityQueue whose elementes are instances of different subclasses.

For example:
Event is an abstract superclass.
Event1, Event2, Event3 are subclasses.
Xpto<> is an interface and PriorityQueueXpto<> is a class that implements Xpto and extends PriorityQueue.

Xpto<? extends Event> a = new PriorityQueueXpto<????>();

Is this possible? How?

Thank you in advance!

Edited 6 Years Ago by msr: n/a

I see no-one has replied to this (wonder why???), so I'll have a go.
Is the following the kind of thing you are looking for?

interface I<T extends Event> {
      T dosomething(T t);
   class Event2 extends Event {

      public Event2(Object arg0, int arg1, Object arg2) {
         super(arg0, arg1, arg2);
   class C<T extends Event> extends PriorityQueue implements I<T> {

      public T dosomething(Event t) {
         // TODO Auto-generated method stub
         return null;
    void test() {
       I<Event2> c = new C<Event2>();
       c.dosomething(new Event2(null, 0, null));

Edited 6 Years Ago by JamesCherrill: Improved sample code

This question has already been answered. Start a new discussion instead.