an interface defines a protocol of behavior and not how we should be implemented.实现接口的类遵循该接口定义的协议。
接口变量是静态的,因为java接口不能单独实例化。变量的值必须在没有实例存在的静态上下文中分配。final修饰符确保分配给接口变量的值是真正的常量cannot be re-assigned. in other words, interfaces can declare only constants, not instance variables.template :interface interfacename{ // any number of final, static variables datatype variablename = value; // any number of abstract method declarations returntype methodname(list of parameters or no parameters);}
以上就是为什么java中的接口变量默认是静态和最终的?的详细内容。