Recursive method, help :)
hi everybody ... this is my method
public Data matchByInd1(Data data, Vector vector, int i) {
Data _data;
Data notFound = new Data("notFound");
if (i < vector.size()) {
_data = (Data) vector.elementAt(i);
if (!_data.isVisited() && matchInd1(data, _data)) {
_data.setVisited();
return _data;
}else {
i+=1;
matchByInd1(fact, kb, i);
}
}
return notFound;
}
Right, this is method is some sort of recursive member function, this is given a vector and a data, the method searches, in the vector, for such a data and if it finds it the data is returned otherwise it returns notFound.
My problem is that this method do finds any given data which is stored in the vector however such a data is not returned. The method always returns the first element stored in the vector.
How I can fix this problem? I do not want to fix it by using for() or while() :) ...
Thank you
Pepe

