反转字符串
反转字符串可以通过reverse来实现,也可以通过迭代方法
实现
package com.example.data;
/**
* *@ClassName reverse
* *@Author yyc
* *@Date 2020/6/15 16:42
**/
public class reverse {
public String reverse(String word)
{
if(word.length()==1)
return word;
else
{
String subString=word.substring(1);
String subSolution=reverse(subString);
String solution=subSolution+word.substring(0,1);
return solution;
}
}
}