subject:คุณลักษณะของ Interface
syntax:interface interface_name
{
attribute;
abstrace method;
}
class class_name implements interface_name
{
method;
}
content:จะมีเพียง attribute และ abstract method เท่านั้น
และไม่สามารถสร้าง object จาก Interface และ SubClass ของ Interface ได้
โดยจะสามารถสร้าง object ได้จาก Implement ของ Interface เท่านั้น
โดยที่ทุกๆ Implement จาก Interface จะต้องทำการ implement ทุก abstract method มาทั้งหมดเสมอ
ส่วนการประกาศ attribute ใน Interface นั้น เหมือนกับการใช้ public final ใน Concrete Class
example:interface Animal
{
public abstract void walk ();
public abstract void run ();
}
class Dog implements Animal
{
public void walk ( )
{
}
public void run ( )
{
}
}