How To Use Interface in Java Programming Language
The Following script is the simplest way to declaring and using interface in Java programming language:
Class diagram:
Java program:
//Sayap = Wing
//Burung = Bird
//Terbang = Fly
interface Sayap{
void terbang();
}
class Burung implements Sayap{
public void terbang(){
System.out.println("Burung bisa terbang karena punya sayap");
//Birds can fly becouse it has wings :)
}
}
class Interface{
public static void main(String args[]){
Burung nuri = new Burung();
nuri.terbang();
}
}
Output:
ShadowOfBdg© - All rights reserved.
No comments:
Post a Comment