日期:2014-05-18 浏览次数:20787 次
interface Xinren
{
public void show();
}
class QQqun
{
public void ren()
{
System.out.println("大家好,我是群主。我叫邵震。");
}
public void useXinren(Xinren q)
{
if (q!=null)
{
q.show();
}
}
}
class laoliu implements Xinren
{
public void show()
{
System.out.println("大家好,我是新来的,我叫刘胜寒");
}
}
class laoge implements Xinren
{
public void show()
{
System.out.println("大家好,我是新来的,我叫老葛");
}
}
class Java0412d2
{
public static void main(String[] args)
{
QQqun qun =new QQqun();
qun.ren();
qun.useXinren(null);
laoliu liu =new laoliu();
liu.show();
laoge ge =new laoge();
ge.show();
}
}
class Java0412d2
{
public static void main(String[] args)
{
Xinren laoliu=new laoliu();
Xinren laoge=new laoge();
QQqun qun =new QQqun();
qun.ren();
qun.useXinren(laoliu);
qun.useXinren(laoge);
}
}