Incompatible return types for method when returning subclass
问题 I am trying to define a method to return all neighbours of a given vertex on a graph given by the signature public abstract class GraphClass<V extends Vertex<?>,E extends Edge<V,?>> implements UndirectedGraph<V,E>{ . . . public ArrayList<V> getNeighbors(V v) {...} } I wish to override this method from my KTree class which extends the above GraphClass as follows public class KTree extends GraphClass<KVertex,KEdge> {... public ArrayList<KVertex> getNeighbors(KVertex v) { return v.getAdjList();