开发者

Cannot convert from type T to type T?

开发者 https://www.devze.com 2023-01-17 22:07 出处:网络
A strange error here using static factory pattern. What am I missing?Here is the code: class subclass<T> extends immutablestruct<T>{

A strange error here using static factory pattern. What am I missing? Here is the code:

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

    //constru开发者_运维问答ctor
<T> subclass(T y, immutablestruct<T> f ){
    this.x = y;  //this is there the error is
    this.f = f;
}


Remove <T> from constructor declaration. Now you're declaring second generic parameter, while you can access old T value:

//constructor
subclass(T y, immutablestruct<T> f ){
0

精彩评论

暂无评论...
验证码 换一张
取 消