interf3

interf3




Definitions of methods are empty


interface AComplenlnterface { void rnethodl() ; void method2 () ;

void methodM () ;

}

class AnAdapter implements AComplenlnterface { public void methodl ()    {};

public void method2 ()

public void methodM ()    { };

}

class A extends AnAdapter {

public void method2 ()    {

ii the body of the method ii carries out sonie operations

}

}

class B extends AnAdapter {

public void method2 ()    {

ii the body of the method ii carries out sonie operations

}

public void method3 ()    {

ii the body of the method ii carries out some operations

}

}

For objects of the class a we want to invoke only the method method2 o, whereas for the objects of the class we will invoke only methods method2 () and method3 ().

If there were no adapter we would be oblidged to supply definitions for all of the methods of the interface (for example methodio ()). not only for the ones we are interested in.

Applying an adapter we may supply definitions for exactly those methods we really need - this way we save time and are not forced to write unnecessary codę.



Wyszukiwarka

Podobne podstrony:
interf3 (2) "Puste" definicje metod interface Rozbudowany Interfejs { voidmetodal(); void
56794 interf3 (2) "Puste" definicje metod interface Rozbudowany Interfejs { voidmetodal();
Definition of the Smith Chart The Smith Chart provides a graphical method for the visualisationof co
interf3 (2) "Puste" definicje metod interface Rozbudowany Interfejs { voidmetodal(); void
font adjust a thafs right - all of these are at the same point (em) size. In CSS, any one of theseSe
Granty Europejskie FP5 Research Training NetWork Projectdama nr csDevelopment and Application of Met
Statistical evaluation of OTA measurements indicates network performance The definiti
498 Because there is no homogenous definition of risk in Insurance Theory, the first part of the art
scan0005 (5) // ■ // V e Look at the following extracts from Silvia’s skills-based CV. What kinds of
Introduction 1 INTRODUCTION TO LITERATURĘ COURSE OUTLINE I.    Definition of Literatu
mbs 013 MY BRKATIIING SYSTEM of gymnastics are to be competed for, or demonstrated at the Games, rea
22401 IMG(62 Number of Inseminations per Ejaculate If a number of mares are to be inseminated with a
Cj> Andela What We Do v    Meet The Developers Resources v Blog Company of project
Agile Tribes Kanban BoardO Definition of Done Point Estimates Planning Poker Backlog Given When
IMGx37 246 The Origin of Civilisation are all graphic i 1lustrations of autonomous rising cultures m

więcej podobnych podstron