Java Reference
In-Depth Information
be a convenient way to make these constants available to each file. In Java, interface vari-
ables offer one solution.
To define a set of shared constants, create an interface that contains only these constants,
without any methods. Each file that needs access to the constants simply “implements” the
interface. This brings the constants into view. Here is an example:
NOTE
The technique of using an interface to define shared constants is controversial. It is de-
scribed here for completeness.
Interfaces Can Be Extended
One interface can inherit another by use of the keyword extends . The syntax is the same
as for inheriting classes. When a class implements an interface that inherits another inter-
Search WWH ::




Custom Search