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();
}
}
欢迎访问:wenhao.ink