An interface is a list of methods that must be defined by any class which implements that interface.
Tutorial Details:
An interface is a list of methods that must be defined by any class which implements that interface. It may also define constants (public static final).
Similar to abstract class. An interface is similar to a class without instance and static variables (static final constants are allowed), and without method bodies. This is essentially what a completely abstract class does, but abstract classes do allow static method definitions, and interfaces don't.
Contractual obligation. When a class specifies that it implements an interface, it must define all methods of that interface. A class can implement many different interfaces. If a class doesn't define all methods of the interfaces it agreed to define (by the implements clause), the compiler gives an error message, which typically says something like "This class must be declared abstract". An abstract class is one that doesn't implement all methods it said it would. The solution to this is almost always to implement the missing methods of the interface. A misspelled method name or incorrect parameter list is the usual cause, not that it should have been abstract!
Rate Tutorial: http://www.roseindia.net/java/java-tips/oop/interfaces/interfaces.shtml
Read
Tutorial at: Click here to view the tutorial
Rate Tutorial: Java: Interfaces
View Tutorial: Java: Interfaces
Related
Tutorials:
|