Final interface in Java?

前端 未结 10 2121
情话喂你
情话喂你 2020-12-03 09:37

Can an interface be declared as final in Java?

10条回答
  •  佛祖请我去吃肉
    2020-12-03 10:34

    final means it can't be modified. If it's a class, it can't be modified by extending (methods can be modified by overriding, attribute's can't be modified; added attributes/methods can only be accessed as members of the 'subclass type'); if its a variable (attribute/local) then the value can't be modified after first assignment; if its a method, the implementation can't be modified (a final method can be overloaded but can't be overridden). There no point in declaring an interface final since there's normally no implementation to modify (default and static interface methods are not allowed to be final).

提交回复
热议问题