你的位置:首页 > Java教程

[Java教程]344. Reverse String


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

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

代码如下:

方法一:

1 public class Solution {2   public String reverseString(String s) {3 4     StringBuffer t=new StringBuffer(s);5     return t.reverse().toString();6   }7 }