科学网于同奎先生的源程序
这个程序我在eclipse下运行sel=SwarmUtils.getSelector(market,"calculate");类似的语句不能运行
似乎缺少了一个SwarmUtils的类,不知道怎么回事
朋友们给个反馈?? import swarm.Selector;
public class SwarmUtils {
public static Selector getSelector(String name, String method) {
Selector sel;
try {
sel = new Selector(Class.forName(name), method, false);
} catch (Exception e) {
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
System.err.println(name + "." + method + " returns " + e.getMessage());
System.err.println("The process will be terminated.");
System.exit(1);
return null;
}
return sel;
}
public static Selector getSelector(Object obj, String method) {
Selector sel;
try {
sel = new Selector(obj.getClass(), method, false);
} catch (Exception e) {
System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
+ (obj.getClass()).getName() + ".");
System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
System.err.println("The process will be terminated.");
System.exit(1);
return null;
}
return sel;
}
} very good. 这个……在SimpleBug的代码中自带了一个SwarmUtils的类……答案如2楼所示……
谢谢
学习学习 请问一下代码是添加在哪里的啊? 是单独建立一个新的JAVA文件,文件名为SwarmUtils.java,然后把上述代码复制进去就可以了:) 学习。
页:
[1]