Implementations and Collections

后端 未结 4 1838
北海茫月
北海茫月 2020-12-21 12:24

Why does this not work...

public ArrayList getEdges() {

return A;

//A is an Arraylist of type \'Action\'. Action implements Ed         


        
4条回答
  •  渐次进展
    2020-12-21 13:10

    Because while Edge is a subtype of Action, ArrayList is not a subtype of ArrayList.

    Use ArrayList instead.

    You could take a look at this tutorial's 4. Wildcard section, although I'd suggest to just read through it, because it is really helpful.

提交回复
热议问题