9.1
Interface Declarations
INTERFACES
9.1 Interface Declarations
An interface declaration specifies a new reference type:
InterfaceDeclaration:
InterfaceModifiers
opt
interface
Identifier
ExtendsInterfaces
opt
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 pack
age cannot have the same name.
9.1.1 Scope of an Interface Type Name
The
Identifier
specifies the name of the interface and has as its scope the entire
package in which it is declared. This is the same scoping rule as for class type
names; see 8.1.1 for an example involving classes.
9.1.2 Interface Modifiers
An interface declaration may be preceded by
interface modifiers
:
InterfaceModifiers:
InterfaceModifier
InterfaceModifiers InterfaceModifier
InterfaceModifier: one of
public abstract
The access modifier
public
is discussed in 6.6. A compile time error occurs if
the same modifier appears more than once in an interface declaration.
9.1.2.1
abstract
Interfaces
Every interface is implicitly
abstract
. This modifier is obsolete and should not
be used in new Java programs.
184
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved