I want to achieve the following.
I have a generic class Node<K,T,V> which looks as follows:
public class Node<K,T,V>{
/**
* @return the key
*/
public K getKey() {
return key;
}
/**
* @param key the key to set
*/
public void setKey(K key) {
this.key = key;
}
// etc...
Now I want to have a class Tree which operates on Nodes with arbitrary parametrized types:
public class Tree <Node<K,V,T>> {
public void insert(Node<K,V,T> node){
K key = node.getKey();
// do something...
}
// ... etc...
}
This, however, does not work, since Eclipse tells me the line public class Tree <Node<K,V,T>> does not look good :) If I change it to
public class Tree <Node> {
It tells me that the type Node is hiding the type Node. How can I achieve that from the Tree class I can properly access the types K, V and T?
I'm pretty sure this question has been answered a bazillion times. I did, however, not find anything at all - so sorry for that!!!
Cheers.