您的位置:寻梦网首页编程乐园Java天地Core JavaJava Lecture Notes
Introduction
Content
Apply
Reflect
Extend
previous.gif
 (3087 bytes)
next.gif
 (2959 bytes)

 
 
Content Index
Content Page # 11

Defining an interface

An interface is defined just like a class, but with the `interface' keyword rather than the `class' keyword. The methods must be defined, but not implemented

For example, the KeyboardListener interface may be defined like this: 

interface KeyboardListener
{
void keyPressed();
void keyReleased();
}
We have said that the KeyboardListener has two methods: keyPressed() and keyReleased() but we have not said how these methods are to be carried out. My intention is that keyPressed() will be called whenever the user presses a key, and keyReleased() when the key is released.

Back to top

basicline.gif (169 bytes)

RITSEC - Global Campus
Copyright © 1999 RITSEC- Middlesex University. All rights reserved.
webmaster@globalcampus.com.eg