9.1 Interface Declarations

An interface declaration specifies a new reference type:

InterfaceDeclaration:
InterfaceModifiersopt interface Identifier
ExtendsInterfacesopt InterfaceBody

A compile-time error occurs if the Identifier naming an interface appears as the name of any other class or interface in the same package. A compile-time error also occurs if the Identifier naming an interface appears as the name by which a class or interface is to be known via a single-type-import declaration (§7.5.1) in the compilation unit containing the interface declaration. In the example:


class Point { int x, y; }
interface Point { void move(int dx, int dy); }

a compile-time error occurs because a class and an interface in the same package cannot have the same name.