Skip to content

Instantly share code, notes, and snippets.

@Guilherme-HRamos
Created June 30, 2019 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Guilherme-HRamos/e251bac7825f2a56718f560902a69ba2 to your computer and use it in GitHub Desktop.
Save Guilherme-HRamos/e251bac7825f2a56718f560902a69ba2 to your computer and use it in GitHub Desktop.
Medium - Android/Java Interfaces like a Boss! - Interface inheritance examples
// 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