There is no way to implement what you want.If you implement this type() interface in you "test" class,
all the type() method in your "inl" and "in2" have been implemented.So, Whatever you cast your "test" to either "in1" or "in2", the same type() method will be called.In fact, this doesn't conflict with Java Language Specification, since the type() method in "inl" and "in2" has same signature. And in runtime, the real method invocation is a late binding that will invoke your implemented code.
all the type() method in your "inl" and "in2" have been implemented.So, Whatever you cast your "test" to either "in1" or "in2", the same type() method will be called.In fact, this doesn't conflict with Java Language Specification, since the type() method in "inl" and "in2" has same signature. And in runtime, the real method invocation is a late binding that will invoke your implemented code.
太麻烦了 唉!!!
--- ZJQ
用接口见解实现多重继承
----------- 谢谢 这一点我已经知道了okyhc(超时) :
自己写个试试不就可以了
----------- 你眼睛不好啊,我已开始不就贴了代码了吗
而不像你这两个接口,全部被重载了
非常实际
对阿
问题是两个方法 名称,返回值,参数 都一样
你又怎么分别详细的定义呢
难道写两个 名称,返回值,参数 都一样 的方法
知道谁是谁啊
:-/
两个interface有相同的函数名有什么关系呢,
java implements interface时只是规定了一个函数名而已,
管他是那个接口的或是自己的当然,严格来讲这是不好的设计。
因为这本来就是一个没有意义的问题
规范都定义好了 照做就行,何必那么麻烦呢
只能说 Java 在这里还有一点缺陷,
但并不影响 Java 的健壮