我希望能够从通用函数内部构造一个对象。我尝试了以下方法:
abstract class Interface
{
Interface.func(int x);
}
class Test implements Interface
{
Test.func(int x){}
}
T make<T extends Interface>(int x)
{
// the next line doesn't work
return T.func(x);
}
Run Code Online (Sandbox Code Playgroud)
但是,这不起作用。而且我收到以下错误消息:The method 'func' isn't defined for the class 'Type'。
注意:我不能使用镜子,因为我正在使用带有飞镖的飞镖。