Reverse String

Write a function that takes a string as input and returns the string reversed.

Example:
Given s = "hello", return "olleh"

思路:直接转StringBuffer后reserve即可;

JAVA CODE

class Solution {
    public String reverseString(String s) {
        StringBuffer ss = new StringBuffer(s);
        return ss.reverse().toString();
    }
}

 

posted @ 2017-08-30 07:37  白常福  阅读(175)  评论(0编辑  收藏  举报