Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法从类型T转换为类型T?_Java - Fatal编程技术网

Java 无法从类型T转换为类型T?

Java 无法从类型T转换为类型T?,java,Java,使用静态工厂模式时出现了一个奇怪的错误。我错过了什么?代码如下: class subclass<T> extends immutablestruct<T>{ private immutablestruct f; private T x; //constructor <T> subclass(T y, immutablestruct<T> f ){ this.x = y; //this is there the error is

使用静态工厂模式时出现了一个奇怪的错误。我错过了什么?代码如下:

class subclass<T> extends immutablestruct<T>{
private immutablestruct f;
private T x;

    //constructor
<T> subclass(T y, immutablestruct<T> f ){
    this.x = y;  //this is there the error is
    this.f = f;
}
类子类扩展了immutablestruct{
私有免疫结构f;
私人信托;
//建造师
子类(TY,immutablestruct f){
this.x=y;//这就是错误所在
这个。f=f;
}
从构造函数声明中删除
。现在您正在声明第二个泛型参数,同时可以访问旧的
T
值:

//constructor
subclass(T y, immutablestruct<T> f ){
//构造函数
子类(TY,immutablestruct f){

no所有小写类名,如果您使用小写
t
而不是
t