I am practicing recursion and using a recursive helper method. In my helper method, an error appears saying that
The method someMethod(K) in the type Tree is not applicable for the arguments (K, List, int).
However, I do not want to use the someMethod(K k)
method as I am trying to use the someMethod(K k, List<K> L, int n)
helper method. How do I make Eclipse "know" that I'm trying to use the other method?
Here's what I have thus far:
public List<K> someMethod(K k) {
List<K> L=new LinkedList<K>();
if (lookup(k) != null) {
return someMethod(k, L, 0);
}
return L;
}
private List<K> someMethod(K k, List<K> L, int n) {
if (this.k.compareTo(k) == 0) {
L.add(this.k);
return list;
}
if (this.k.compareTo(k) < 0) {
right.someMethod(k, L, n); //error here
L.add(this.k);
}
if (this.k.compareTo(k) > 0) {
left.someMethod(k, L, n); //error here
L.add(this.k);
}
}
Edit: declarations for left and right:
private Tree<K, V> left, right;