There are two features of the interface:
--The interface cannot have instance fields (instance variables) --Cannot implement concrete methods (methods that are not abstract methods)
In the interface, when you try to declare a field, it is treated as if you declared a constant like public static final
.
Only abstract methods can be defined, and when an interface is implemented, the abstract method must be overridden when an instance is created.
Be careful when creating classes instead of interfaces for commonality of each class. If each class is a subclass of some kind, it is not possible to inherit what was made into a common class. Because in Java, you can only have one superclass. If it is an interface, it is possible to implement multiple.
Recommended Posts