2 Replies Latest reply: Mar 3, 2010 5:37 AM by 800268 RSS

    how to inherit generic constructor

    843793
      I have a super class with below generic constructor:
      public class Super {
           public Super(){}
           public <T extends Collection<?>> Super( T sub){
                // Do something
           }
      }
      I hope all the sub classes of Super will inherit this constructor and will accept a collection of its sub classes, so I have:
      public class Sub extends Super {
      }
      but when initiating the Sub class with a List<Sub>:
      List<Sub> x = null;
      Sub sub = new Sub(x);
      I met compiler error: the constructor Sub(List<Sub>) is undefined.