接口可使用的修饰符如下:
InterfaceModifier: one of
Annotation public protected private
abstract static strictfp
接口中可声明的一些成员:
InterfaceMemberDeclaration:
ConstantDeclaration
AbstractMethodDeclaration
ClassDeclaration
InterfaceDeclaration
The modifier static pertains only to member interfaces (§8.5.1, §9.5), not to top level interfaces (§7.6).
The access modifiers protected and private pertain only to member interfaces within a directly enclosing class or enum declaration (§8.5.1).
9.1.1.2. strictfp Interfaces
The effect of the strictfp modifier is to make all float or double expressions within the interface declaration be explicitly FP-strict (§15.4).
This implies that all nested types declared in the interface are implicitly strictfp.
It is a compile-time error to refer to a type parameter of an interface I anywhere in the declaration of a field or type member of I.
9.1.3. Superinterfaces and Subinterfaces
If an extends clause is provided, then the interface being declared extends each of the other named interfaces and therefore inherits the member types, methods, and constants of each of the other named interfaces.
Given a (possibly generic) interface declaration for I<F1,...,Fn>(n ≥ 0), the direct superinterfaces of the interface typeI<F1,...,Fn> are the types given in the extends clause of the declaration of I if an extends clause is present.
Let I<F1,...,Fn> (n > 0), be a generic interface declaration. The direct superinterfaces of the parameterized interface type I<T1,...,Tn>, where Ti (1 ≤ i ≤ n) is a type, are all types J<U1θ,...,Uk θ>, where J<U1,...,Uk> is a direct superinterface ofI<F1,...,Fn>, and θ is the substitution [F1:=T1,...,Fn:=Tn].
9.2. Interface Members
The members of an interface are:
-
If an interface has no direct superinterfaces, then the interface implicitly declares a
publicabstractmember methodmwith signature s, return type r, andthrowsclause t corresponding to eachpublicinstance methodmwith signature s, return type r, andthrowsclause t declared inObject, unless a method with the same signature, same return type, and a compatiblethrowsclause is explicitly declared by the interface.It is a compile-time error if the interface explicitly declares such a method
min the case wheremis declared to befinalinObject.It follows that is a compile-time error if the interface declares a method with a signature that is override-equivalent (§8.4.2) to a
publicmethod ofObject, but has a different return type or incompatiblethrowsclause.
The interface inherits, from the interfaces it extends, all members of those interfaces, except for (a) fields, classes, and interfaces that it hides and (b) methods that it overrides (§9.4.1).
Fields, methods, and member types of an interface type may have the same name, since they are used in different contexts and are disambiguated by different lookup procedures (§6.5). However, this is discouraged as a matter of style.