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 
RITSEC - Global Campus Copyright © 1999 RITSEC- Middlesex University. All rights reserved. webmaster@globalcampus.com.eg |