您的位置:首页 > 编程语言 > Java开发

用内部类实现java多重实现中的方法同名问题

2012-05-08 22:18 309 查看
//实现两个名字一样但返回值不一样的方法;

public class TestClass implements A {
public int a() {
return 1;
}
private static class Inner implements B {
public void a() {
System.out.println("public void a()");
}
}

public static void main(String[] args) {
TestClass tc = new TestClass();
Inner i = new Inner();
i.a();
System.out.println(tc.a());
}

}

interface A {
public int a();
}

interface B {
public void a();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐