Assign a subclass of a Generic class to a super class of this class

后端 未结 5 2113
心在旅途
心在旅途 2020-12-11 19:58

I have couple of supplied interfaces

public interface Finder,T extends Item> {
    public S find(S s, int a);
}

public interf         


        
5条回答
  •  误落风尘
    2020-12-11 20:17

    Your type S is a subtype of Stack but the copy method is upcasting it to a Stack that may be any subtype of Stack. You will have to cast the result of copy to S

提交回复
热议问题