I am trying to find the string with the largest number of lowercase letters in a list recursively. For some reason I can not find more than StackOverFlow
errors. Could someone tell me what's wrong? I think I'm covering the base case and so on:
public static String cadenaMayorMinusculasRecursivo (List<String> l, Integer mins, Integer i, String res) {
if(l.size()==0) {
return "La lista está vacía";
}
else if(i.equals(l.size()-1)) {
return l.get(i);
}
else {
mins = caracteresMinusculaStream(l.get(i)) > mins ? caracteresMinusculaStream(l.get(i)) : mins;
res = caracteresMinusculaStream(l.get(i)) > mins ? l.get(i) : res;
return cadenaMayorMinusculasRecursivo(l, mins, i++, res);
}
}
The methods do what their name suggests, and the variables mins
and res
are intended to store the maximum number of lowercase letters found so far and the string with the highest number of lowercase letters, respectively. I have the function instantiated such that:
System.out.println(cadenaMayorMinusculasRecursivo(lista, 0, 0, ""));
Any help given is appreciated in advance.