由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - a question on interface
相关主题
Question: reflection and generics有人用eclipse吗?
这个方法到底如何调用的?anybody familiar w/ Axis? targetService is null
A question about inheritance谁深入解答一下Java的Reflection机制
invoke a function dynamically in Java?How does a client find and connect to a specific
有没有完美的写configuration文件的方案What specific services does a container provide f
can applet implements runnable?Re: Can create a Interface object, why?
问一个特别土的问题[转载] help please on Java
interface和implementation class问题征解
相关话题的讨论汇总
话题: interface话题: question话题: method话题: getmethod话题: class
进入Java版参与讨论
1 (共1页)
P*P
发帖数: 36
1
我有一个interface定义了一个method A,两个class implements了这个interface,meth
od A.如果另一个class要调用这个method A,怎么制定要用哪个implementation呢.谢谢
g*****g
发帖数: 34805
2
是那个类的实例就会用那个。

meth

【在 P*P 的大作中提到】
: 我有一个interface定义了一个method A,两个class implements了这个interface,meth
: od A.如果另一个class要调用这个method A,怎么制定要用哪个implementation呢.谢谢

w*r
发帖数: 2421
3
instanceof(o).getMethod("methodname").invoke(o,...)

meth

【在 P*P 的大作中提到】
: 我有一个interface定义了一个method A,两个class implements了这个interface,meth
: od A.如果另一个class要调用这个method A,怎么制定要用哪个implementation呢.谢谢

h*********o
发帖数: 62
4
That is quite a fancy call.

【在 w*r 的大作中提到】
: instanceof(o).getMethod("methodname").invoke(o,...)
:
: meth

w*r
发帖数: 2421
5
so far this is the standard way to figure out which method you are hitting.
And it is the basic methodology deployed by spring

【在 h*********o 的大作中提到】
: That is quite a fancy call.
h*********o
发帖数: 62
6
first, I do not see reflective invocation has anything to do with the
original question. maybe I do not see things deep enough.
second, getmethod is a method belongs to class metadata, you can not call it
on an object instance , nor on instanceof operator.
third, getmethod(String) only returns method object. If you can somehow to
figure out which class metadata to use, you already answer the question, no
need to make the function call using reflection.
1 (共1页)
进入Java版参与讨论
相关主题
问题征解有没有完美的写configuration文件的方案
JAVA DOC 的问题can applet implements runnable?
问一个J2EE和Tomcat问题问一个特别土的问题
问一个版权的问题 (转载)interface和implementation class
Question: reflection and generics有人用eclipse吗?
这个方法到底如何调用的?anybody familiar w/ Axis? targetService is null
A question about inheritance谁深入解答一下Java的Reflection机制
invoke a function dynamically in Java?How does a client find and connect to a specific
相关话题的讨论汇总
话题: interface话题: question话题: method话题: getmethod话题: class