Interfaces and Abstract Classes : Interface « Class Definition « Java Tutorial
- Java Tutorial
- Class Definition
- Interface
- The interface should be regarded as a contract between a service provider and its clients.
- An abstract class is a class that cannot be instantiated
- An abstract class must be implemented by a subclass.
- In Java, the interface is a type.
Follow this format to write an interface:
accessModifier interface interfaceName {
}
public interface Printable {
void print (Object o);
}
- The Printable interface has a method, print.
- print is public even though there is no public keyword.