Reputation: 3
I got the following error:
name clash: add(E) in AVLTree<E> and add(E) in BinaryTree have the same erasure, yet neither overrides the other
and I have no idea what the problem is.
public class BinaryTree<E extends Comparable<E>> implements Iterable<E> {
public class AVLTree<E extends Comparable<E>> extends BinaryTree {
the add method in both classes is written as:
public void add(E toInsert) {
I hope I provided everything i needed. I'm stumped by this so any help would be appreciated, thanks.
Upvotes: 0
Views: 163
Reputation: 425063
Looks like AVLTree is an inner class, so the parameterized type E
is visible. Try this:
public class BinaryTree<E extends Comparable<E>> implements Iterable<E> {
public class AVLTree extends BinaryTree<E> {
I must say it's a little weird having an inner class extend its containing class. Not implausible; I've just never seen it done before.
Upvotes: 1