Co se tyce toho, zda tuto anotaci pouzivat, tak jsem nekde cetl a souhlasim s tim, ze je dobre ji pouzivat. Tato anotace vam zajisti kontrolu nad tim, zda dana metoda opravdu prekryva metodu predka. U implementace rozhrani to neni az tak dulezite, jelikoz v pripade zmeny rozhrani vam kompilator vyhodi chybu tak jako tak, ze metoda neni implementovana. Jina situace je ale v pripade, ze prekryvame metodu od predka a pocitame s tim, ze se bude volat ta prekryta metoda. v pripade, ze dojde ke zmene v implementaci u potomka (prida se parametr, zmeni se typ parametru) tak se nemusi tato zmena projevit jako chyba v okoli daneho objektu, ktere jej vyuziva, ale fakticky to bude delat neco jineho, nez se puvodne predpokladalo (bude se volat metoda predka a ne ta prekryta). Tato anotace nam zajisti vyhozeni chyby, ze metoda jiz neni prepisem jine metody, ale ze mame dve samostatne metody.

Jaroslav Hurdes

Dne 8.3.2010 16:27, Marian Stevlik napsal(a):
Hi all,

Chcel by som sa spytat, ci sa ma uvadzat anotacia @Override nad
implementaciou metody interfaceu?
Ide o Javu 1.6

Priklad:

public interface NejakyInterface {

   public void nejakaMetoda();

}

public class NejakyInterfaceImpl implements NejakyInterface {

   @Override // Anotacia ano ci nie?
   public void nejakaMetoda() {
     // nejaky kod
   }

}

Pytam sa preto, bo NetBeans 6.8 mi davaju warning, ze by tam anotacia
mala byt, ale Eclipse Galileo mi tam potom hadzu chybu a odporucaju
anotaciu vymazat.

Michal


______________________________________________________
The information contained in this communication is intended solely for the use 
of the individual or entity to whom it is addressed and others authorized to 
receive it. It may contain confidential or legally privileged information. If 
you are not the intended recipient you are hereby notified that any disclosure, 
copying, distribution or taking any action in reliance on the contents of this 
information is strictly prohibited and may be unlawful. If you have received 
this communication in error, please notify us immediately by forwarding this 
email to [email protected] and then delete it from your system.

Ness Technologies is neither liable for the proper and complete transmission of 
the information contained in this communication nor for any delay in its 
receipt.


Odpovedet emailem