26 ก.ย. 2554

Java Interface

Interface A.java

public interface A {
 void iamA(); 
 void helloA();
}

B.java

public class B implements A{
 @Override
 public void iamA() {
  System.out.println("I am A use by B");
 }
 @Override
 public void helloA() {
  System.out.println("Hello World A");
 }
}

Use.java

public class Use {
 public static void main(String[] args) {
  B b = new B();
  b.iamA();
  b.helloA();
 }
}

Result:  I am A use by B
         Hello World A

ไม่มีความคิดเห็น:

แสดงความคิดเห็น