How can I combine a generic class with a generic type?
Hello,
I am trying to build a generic class that using a generic type.
The genrics types using a method from Node and Pair.
like this example:
public class Graph <E extends Node,P extends Pair> {
.
.
.
}
Graph is a genric class, also Node and Pair.
Node is a generic class that his constructor get 1 generic type:
public class Node <E> {
.
.
}
Pair is also a genric type that his constructor can get 2 generic type:
public class Pair <E,T>{
.
.
.
}
Can anybody know this solution?
class Node < T > {}
class Pair < E, T > {}
class Graph < E, T, N extends Node < T > , P extends Pair < E, T > > {}
hi, thanks for your quick answer.
The problem that the code is compile without errors only when I compile your solution at the same file. But when I separate the file into 3 files : Graph.java , Node.java and Pair.java, I get an error:
ERROR:
Graph.java:5: cannot find symbol
symbol: class Node
class Graph < E, T, N extends Node < T > , P extends Pair < E, T > > {}
^
Graph.java:5: cannot find symbol
symbol: class Pair
class Graph < E, T, N extends Node < T > , P extends Pair < E, T > > {}
^
2 errors
Can you explain this?
thanks.