My task was : I have to return string "." many times as integer n was given. but also I have to return the first n all this using recursion how do I do it?
My code :
private static String recString(final int i) {
return (i==0 ? "" : i>0 ? recString(i)+ recString(i-1)+"." : "."+recString(i+1));
}
Aucun commentaire:
Enregistrer un commentaire