i know what an interface is. but i dont understand what the use of connecting the objective reference to the interface method and then use it to implement..
could someone explain to me the code..whats going on/
interface TextReceiver {
void receiveText( String text );
}
class TickerTape implements TextReceiver {
public void receiveText( String text ) {
System.out.println("TICKER:\n" + text + "\n");
}
}
class TextSource {
TextReceiver receiver;
TextSource( TextReceiver r ) {
receiver = r;
}
public void sendText( String s ) {
receiver.receiveText( s );
}
}