Write a function that takes a string as input and returns the string reversed.
public class Solution {
public String reverseString(String s) {
StringBuffer sb=new StringBuffer(s);
sb.reverse();
String a=sb.toString();
return a;
}
}
本文介绍了一个使用Java实现的字符串反转函数,通过StringBuffer类的reverse()方法实现了字符串的逆序输出。
2193

被折叠的 条评论
为什么被折叠?



