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?

[631 byte] By [Java.Studenta] at [2007-11-27 6:05:12]
# 1

class Node < T > {}

class Pair < E, T > {}

class Graph < E, T, N extends Node < T > , P extends Pair < E, T > > {}

Hippolytea at 2007-7-12 16:50:46 > top of Java-index,Java Essentials,Java Programming...
# 2

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.

Java.Studenta at 2007-7-12 16:50:46 > top of Java-index,Java Essentials,Java Programming...
# 3
Are Node and Pair in the same package as Graph?If not you need to import them.
dwga at 2007-7-12 16:50:46 > top of Java-index,Java Essentials,Java Programming...
# 4
yes.
Java.Studenta at 2007-7-12 16:50:46 > top of Java-index,Java Essentials,Java Programming...
# 5
Is your classpath correct?Please post the command you use to compile.
dwga at 2007-7-12 16:50:46 > top of Java-index,Java Essentials,Java Programming...
# 6
Oops...thanks.
Java.Studenta at 2007-7-12 16:50:46 > top of Java-index,Java Essentials,Java Programming...
# 7
You're welcome, although it would be nice for others that might stumble upon this thread to know what the solution was.You can give the dukes to Hippolyte.
dwga at 2007-7-12 16:50:46 > top of Java-index,Java Essentials,Java Programming...
# 8
> You can give the dukes to Hippolyte.Thanks, dawg.
Hippolytea at 2007-7-12 16:50:46 > top of Java-index,Java Essentials,Java Programming...