java学习之implemetns例程

//声明Hello接口
interface Hello {

public void sayhello();
}
//声明World接口
interface World{
public void sayworld();
}

//定义类Student,继承Hello,World接口
class Student implements Hello,World{
//复写两个接口
public void sayhello()
{
System.out.print("hello");
}
public void sayworld()
{
System.out.println(" world!"+"\n");
}
}

public class Test{
public static void main(String args[])
{
Student p = new Student();
p.sayhello();
p.sayworld();
}
}



posted @ 2011-10-11 22:06  hnrainll  阅读(622)  评论(0编辑  收藏  举报