我有一个名为 HelloWorld 的类,我在其中创建了一个 Class Test test = new Test(); 的对象
然后在 HelloWorld 类中我有我的主要功能和另一个:
public static int passMe(){
System.out.println("running this function");
return 1;
}
这是我试图通过的功能。我使用以下方法通过了 int 测试:
test.getSomeFunction(new Callable<Integer>(){
public Integer call(){
return passMe();
}
});
在测试类里面我有:
public void getSomeFunction(Callable<Integer> someFunction){
System.out.println(someFunction);
}
现在所有这些都有效,但是 passMe() 没有运行,而是我不知道如何引用它。如果我打印出 someFunction,我会得到:
"HelloWorld$1@35a8767"
所以我的问题是如何运行我传入的函数,如果我执行 someFunction() 我收到错误消息“他的方法 someFunction() 未定义类型 Test”