Why interfaces must be declared in Java?
Sometimes we have several classes that have some methods with the same signature, but that don't correspond to a declared Java interface. For example, both JTextField and JButton (among several others in javax.swing.* ) have a method public void addActionListener(ActionListener l) Now, suppose I wish to do something with objects that have that method; then, I'd like to have an interface (or perhaps to define it myself), e.g. public interface CanAddActionListener { public void addActionListener(ActionListener l); } so that I could write: public void myMethod(CanAddActionListener aaa,