Created
June 30, 2019 21:21
-
-
Save Guilherme-HRamos/e251bac7825f2a56718f560902a69ba2 to your computer and use it in GitHub Desktop.
Medium - Android/Java Interfaces like a Boss! - Interface inheritance examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Interface usada na herança | |
interface ParentInterface { | |
void firstMethod(); | |
void secondMethod(); | |
} | |
// Interface derivada de ParentInterface | |
interface ChildInterface extends ParentInterface { | |
// Herança | |
// 1.Não é necessário sobrescrever os métodos herdados de | |
// ParentInterface nesta interface | |
// 2.É possível converter métodos abstratos herdados em métodos padrões sobrescrevendo-os | |
// 3.A classe que implementar esta interface deverá sobrescrever os | |
// métodos abstratos herdados de ParentInterface | |
@Override | |
default void secondMethod() { | |
// some code here | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment