To declare a class that uses an interface, you take in an implements clause in the declaration of a class . Your class is permitted to implement multiple interfaces, so the implements keyword is followed by a comma-separated catalog of the interfaces implemented by the class.
Take an example of interface that describes how to evaluate the size of objects.
Code:
public interface Relatable {
// this (object invoking isLargerThan) and
// other should be object of the same class
// public int isLargerThan(Relatable other);
}
If you want to be capable to contrast the size of related objects, no issue what they are, the class that instantiates them must implement Relatable. Once you are aware that a class implements Relatable, then you are quite familiar that you can contrast the size of the objects created from that class.
Bookmarks