Reputation: 543
I'm having a problem with Generic Types in static method. I have this code:
public class BST<E extends Comparable<E>> {
public static class Node<T> {
private T value;
private Node<E> left, right, parent;
private Node(T v) {
value = v;
}
public String toString() {
return value.toString();
}
}
....
}
then i wanna use Node in this static method:
public static <E> boolean equalTrees(Node<E> r1, Node<E> r2)
but at Node is giving me this error:
The member type BST.Node must be qualified with a parameterized type, since it is not static
I've searched and can't find the answer to that.
Upvotes: 3
Views: 2159
Reputation: 235984
Try this:
public class BST<E extends Comparable<E>> {
public static <E> boolean equalTrees(Node<E> r1, Node<E> r2) {
return false;
}
public static class Node<E> {
private E value;
private Node<E> left, right, parent;
}
}
Upvotes: 2