Preface: c ++ to learn a lot of java have forgotten
interface (interface) can be thought of as a "pure" abstract classes. It allows the creator to the provisions of the basic form of a class: method names, argument lists, and return types, but does not implement the method body
Interface also contains the basic data types of data members, but they are by default public
, static
and final
.
The method defined in the interface by default public
, abstract
.
Why member variables Java interface by default (public, static, final), members of the method (public, abstract) it?
The reason: the interface is a highly abstract template, member variables interface is part of the template, the interface implementation class must be a member of a total of these variables, modifiers member variables default to public, static, final. static so as to achieve this interface, this variable can be used directly.
If the non-static variable, multiple interface implementation class variable name may duplicate names phenomenon.
It represents a final modified variable constant can not be modified. It is a both a static field represents the final period can not be changed only occupy storage space. If the non-final variable, the interface implementation class variable's value may be modified, which is indistinguishable from the abstract class.
Since the interfaces play a role in standardization and regulation, so its member variables default modifier is static, final.