4 Replies Latest reply: Mar 29, 2009 11:22 PM by 807588 RSS

    Generic implements

      Hi, Is it possible to allow only classes that implement a certin interface in a generic class.

      import java.awt.event.*;

      public class ButtonListener<T> implements ActionListener {
      private T t;

      public ButtonListener(T t){
      this.t = t;

      public void actionPerformed(ActionEvent evt){

      But only classes that implent the PerformedAction interface are allowed to be passed to the class as T.

      So in other words T must implement PerformedAction.