|
NOTA: La traducción de esta documentación es un esfuerzo personal y voluntario, no es un documento oficial de Sun Microsystems
ni Oracle ni está patrocinado por ninguna de estas empresas. Los documentos originales (en inglés) están disponibles en:
http://java.sun.com/docs/books/tutorial/.
Dirija cualquier comentario, petición, felicitación, etc. a tutorialesjava_@RROBA_codexion.com. |
Si desea ayudar a mantener en funcionamiento esta web, colaborar con la traducción de estos documentos o necesita que se traduzca algĂșn capĂtulo en concreto puede realizar una donación directa mediante Paypal:
|
Consider an interface that you have developed calledDoIt:Suppose that, at a later time, you want to add a third method topublic interface DoIt { void doSomething(int i, double x); int doSomethingElse(String s); }DoIt, so that the interface now becomes:If you make this change, all classes that implement the oldpublic interface DoIt { void doSomething(int i, double x); int doSomethingElse(String s); boolean didItWork(int i, double x, String s); }DoItinterface will break because they don't implement the interface anymore. Programmers relying on this interface will protest loudly.Try to anticipate all uses for your interface and to specify it completely from the beginning. Given that this is often impossible, you may need to create more interfaces later. For example, you could create a
DoItPlusinterface that extendsDoIt:Now users of your code can choose to continue to use the old interface or to upgrade to the new interface.public interface DoItPlus extends DoIt { boolean didItWork(int i, double x, String s); }