关于接口的问题

tanrui 2004-03-02 09:43:35
假如有两个接口IBase1,IBase2:
interface IBase1
{
void hello();
}

interface IBase2
{
void hello()
}

Test类实现了这两个接口,
public class Test implements IBase1,IBase2
Test怎么样显式的分别实现IBase1和IBase2的hello()方法,以至下面的代码分别调用IBase1和IBase2的hello()的具体实现?

Test t = new Test();
IBase1 ib1;
IBase2 ib2;
ib1 = (IBase1)t;
ib2 = (IBase2)t;
ib1.hello();
ib2.hello();

谢谢!
...全文
18 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧