0

From Java How To Program Deitel book:

Create a single inner class that both extends MouseAdapter and implements MouseMotionListener to handle all mouse events in one class.

According to Java API, MouseAdapter already implements MouseMotionListener. So wouldn't it be redundant to have a class like the following?

private class MyEventHandler extends MouseAdapter implements MouseMotionListener
{
      // class code here
}
Xel
  • 540
  • 2
  • 8
  • 27
  • Yes, it is redundant. Someone might think it is making their code clearer (for some reason), but it is not required for the code. – khelwood Jan 12 '17 at 12:19
  • It’s redundant for an API like this, that you can safely assume to be stable. Of course, if `MouseAdapter` was changed after compiling your program to not implement `MouseMotionListener` anymore, it made a difference. – Holger Jan 24 '17 at 10:32

0 Answers0