09-04 java interface
Export of interface
Going back to our cat and dog case, let's think that dogs are usually gatekeepers and cats are usually pets, right. However, there are many trainers or animal trainers who can train cats to drill the fire circle, dogs to jump high, dogs to do calculations, etc.
Not all cats or dogs have these extra movements from the beginning. They should be trained by special training, right.
Therefore, it is not appropriate to define these additional actions in animals or directly in cats or dogs, because only some cats and dogs have these functions.
Therefore, in order to reflect the extensibility of things' functions, Java provides interfaces to define these additional functions without specific implementation. In the future, which cats and dogs need to be trained, only these cats and dogs need to implement these additional functions.
Characteristics of interface
Member characteristics of interface
Class to class, class to interface, interface to interface relationship
Differences between abstract classes and interfaces:
Cat and dog case, add the additional function of high jump