abstract class MouseAdapter vs. interface
Posted
by Stefano Borini
on Stack Overflow
See other posts from Stack Overflow
or by Stefano Borini
Published on 2010-03-25T08:31:57Z
Indexed on
2010/03/25
8:43 UTC
Read the original article
Hit count: 294
I noted this (it's a java.awt.event class).
public abstract class MouseAdapter implements MouseListener,
MouseWheelListener,
MouseMotionListener {
....
}
Then you are clearly forced to extend from this adapter
public class MouseAdapterImpl extends MouseAdapter {}
the class is abstract and implements no methods. Is this a strategy to combine different interfaces into a single "basically interface" ? I assume in java it's not possible to combine different interfaces into a single one without using this approach.
In other words, it's not possible to do something like this in java
public interface MouseAdapterIface extends MouseListener,
MouseWheelListener,
MouseMotionListener {
}
and then eventually
public class MouseAdapterImpl implements MouseAdapterIface {}
Is my understanding of the point correct ? what about C# ?
© Stack Overflow or respective owner