Skip to content

Instantly share code, notes, and snippets.

@mrnirva
Last active September 22, 2020 15:58
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 mrnirva/0fdd21eaa050b2a081d797315059b231 to your computer and use it in GitHub Desktop.
Save mrnirva/0fdd21eaa050b2a081d797315059b231 to your computer and use it in GitHub Desktop.
package interfaces;
public class Arayuzler {
public static void main(String[] args) {
Kopekler kopek = new Kopekler();
Koyunlar koyun = new Koyunlar();
kopek.yemekYe();
koyun.yemekYe();
}
}
// Arayüz tanımlarken interface ile belirlenir
// Daha sonra arayüze bir isim verilir
interface Hayvanlar{
// Gövdesiz metot yazılır
void yemekYe();
}
// implements kelimesi ile miras alınır
class Kopekler implements Hayvanlar{
// Metot içeride ezilerek yeniden yazılır
@Override
public void yemekYe() {
System.out.println("Et Ye");
}
}
class Koyunlar implements Hayvanlar{
@Override
public void yemekYe() {
System.out.println("Ot Ye");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment