import java.lang.reflect.*; import java.io.*; ...static void getInterfaceNames(Object o) { Class c = o.getClass(); Class[] theInterfaces = c.getInterfaces(); for (int i = 0; i < theInterfaces.length; i++) { Class cc = theInterfaces[i]; //get interface String interfaceName = cc.getName(); //get name of interface } }
是啊~~~~要在b类中创建a的实例,调用用a类的方法~~~~
: yabbi21(yabbi21) 我看不懂你写的是什么意识,体会不来与我的问题的关系,我是要在b类中创建a的实例,然后调用用a类的方法~~~~如果a与b是在同一个文件就可以实现创建,但是在同一个目录就不幸了,因为他不能够创建a类的引用,接受产生的object对象,因为我创建a类的引用时,structure 的err中出现了can't resolve symbol class a. 请指点,谢谢!!!
譬如: jb中有个工程:test下有个类:class hello(){ hello(){} Methods(){} } 和类 class ShowMethods{ class c=Class.forname(hello); //怎么创建hello的对象;取得hello方法methods() // hello h;这样不行,因为hello与ehowmethods不在一个文件。}
import java.io.*;
...static void getInterfaceNames(Object o) {
Class c = o.getClass();
Class[] theInterfaces = c.getInterfaces();
for (int i = 0; i < theInterfaces.length; i++) {
Class cc = theInterfaces[i]; //get interface
String interfaceName = cc.getName(); //get name of interface
}
}
请指点,谢谢!!!
jb中有个工程:test下有个类:class hello(){
hello(){}
Methods(){}
}
和类
class ShowMethods{
class c=Class.forname(hello);
//怎么创建hello的对象;取得hello方法methods()
// hello h;这样不行,因为hello与ehowmethods不在一个文件。}