Declaring an Interface


An interface declaration consists of the interface keyword and interface name . The declaration can also optionally include modifiers and can indicate if the interface extends (inherits from) a superinterface.

 [modifiers] interface interface_name                 [extends superinterface(s)] {    //  method declarations    //  constant declarations } 

The body of the interface, usually consisting of method and constant declarations, is surrounded by braces. Interfaces can have public or default access. A public interface is available to any other code. An interface with default (unspecified) access is only available to other members of the package in which it is declared. Only one public interface can exist in a given file.

Example: Declaring Interfaces

See the example in the "Interface Members" section where the Electrostatic interface is declared.



Technical Java. Applications for Science and Engineering
Technical Java: Applications for Science and Engineering
ISBN: 0131018159
EAN: 2147483647
Year: 2003
Pages: 281
Authors: Grant Palmer

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net