简体   繁体   中英

Is it possible to implement a class with a parameter of type <Generic extends X>?

I'm trying to create a new class that looks like this:

public class WikiGraph<V extends Node> implements DirectedGraph<V extends Node> 

It seems that this is illegal, and when I extend the graph and try to use a parameter that is a subclass of Node, this is a problem. I'm trying to create a subclass that looks like this:

 public class WikiGraphWeighted<WeightedNode> implements DirectedGraph<WeightedNode> 

Are there any workarounds for this. Is what I'm trying to do even possible?

The constraint on V remains in force when it's used elsewhere in scope.

public class WikiGraph< V extends Node > implements DirectedGraph< V > {

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM