- If you want to require a class to implement certain methods, and
those requirements are not appropriate for an abstract class in the
ordinary inheritance chain, then you should define an interface.
- If you want to define a public interface, then instantiate the
following pattern:
public interface interface name {
...
}
- If you want every implementer of an interface to define a particular
method, then you should define an abstract method in the interface by
instantiating the following pattern:
public abstract return type method name
(parameter specifications) ;
- If you want to impose requirements on a particular class using an
interface, then instantiate the following pattern. You may add a
superclass name before the
interface
keyword, marking the
superclass name with the extends
keyword. You may add additional
interface names, separating them with commas:
public class class name implements interface name {
...
}
- No class can extend more than one superclass; any class can implement
multiple interfaces.
- You can use interface names as variable or parameter type declarations.