[LeetCode]反转字符串

将字符串包装为StringBuilder对象,再调用该对象的reverse方法即可反转

问题链接:https://leetcode-cn.com/explore/interview/card/top-interview-questions-easy/5/strings/32/

代码:

    public String reverseString(String s) {
        String res= new StringBuilder(s).reverse().toString();
        return res;
    }

猜你喜欢

转载自blog.csdn.net/sinat_37273780/article/details/84775702