Interfaces specify only what a class can do (or which contracts it obeys) and not how the class does this. On the other hand, non-related classes can share some common behavior. If we somehow could write this behavior in one place, we would be following the Don't Repeat Yourself principle (DRY).
Note
The DRY principle aims at reducing repetition. We can look at a method, a function, or a class as a piece of knowledge. This means that a function or method knows how to do something. The principle tells us not to duplicate this know-how.
It is easier to change this one piece or replace it with another, as this won't affect other logically unrelated elements. Brian Kernighan, the legendary programmer, calls this the Single Point Of Truth (SPOT) principle.
Refer to http://www.linuxtopia.org/online_books/programming_books/art_of_unix_programming/ch04s02_2.html for more on this important design principle.
Let's try the following code as an example of an interface:
// NameIt.java public...