| Java FAQ | ||
| JSP FAQ | ||
| Servlet FAQ | ||
XyzWs Java FAQ:
Why Interface is useful?
Printer-friendly version |
Mail this to a friend
|
Advertisement
|
Why Interface is useful?In Java, an interface defines new a type including a set of unimplement operation on it. An interface defines a protocol of behavior that can be implemented by any classes. A non-abstract class that implements the interface must implement all the methods defined in the interface. The interface presents what its methods are and leave how to do them to the implementation class. A same method in the interface can have totally different implementation in different classes. The interface provides a clearner separation of behavior and implementation. Because the class must implement all the methods defined in the interface, any changes on the method of the interface will affect to all the classes that implements the interface. |