The UML diagram representing the interface is similar to the UML diagram representing the class. A rectangle is used to describe the main components of an interface, and the rectangle is divided into three layers vertically.
The first layer at the top is the name layer. The name of the interface must be in italics, and the name needs to be modified with <<interface>>, and the modification and the name must be listed on two lines.
The second layer is the constant layer, which lists the constants and types in the interface. The format is "constant name:type".
The third layer is the method layer, also called the operation layer, which lists the methods and return types in the interface. The format is "method name (parameter list): type".
The UML diagram of the interface Computable is as follows:
If a class implements an interface, then the relationship between the class and the interface is an implementation relationship, and the class is said to implement the interface. UML connects a class and the interface it implements by using a dotted line. The starting end of the dotted line is the class, and the end end of the dotted line is the interface it implements, but a hollow triangle is used at the end end to represent the end of the dotted line.
The UML diagram of China and Japan classes implementing the Computable interface is as follows: