Interface can only contain abstract methods, properties but we don’t
need to put abstract and public keyword. All the methods and properties
defined in Interface are by default public and abstract.
接口中的每个字段都是公共的、静态的和最终的,因为...
Interface variables are static because Java interfaces cannot be instantiated
in their own right; the value of the variable must be assigned in a static
context in which no instance exists. The final modifier ensures the value
assigned to the interface variable is a true constant that cannot be
re-assigned by program code.
前任:
public interface Test
{
int value = 3; //it should be same as public static final int value = 3;
}
在接口的成员函数的情况下。
A method declaration within an interface is followed by a semicolon,
but no braces, because an interface does not provide implementations
for the methods declared within it. All methods declared in an interface
are implicitly public, so the public modifier can be omitted.
意味着方法在接口中不是最终的。
有关更多详细信息,请参阅本教程