I am trying to capitalize each letter in the given string recursively. I have tried this code:
public static String recs(String s){
return Character.toString(Character.toUpperCase(s.charAt(0)))+recs(s.substring(1));
}
But this code is showing java.lang.StringIndexOutOfBoundsException: String index out of range: 0 exception.