字符串反转的简单实现方式

大华的一道面试题:

package cn.zstu.mytest;
import org.junit.Test;

/**
 * 字符串的反转
 * 例 s="hello",return "olleh"
 * @author faz
 *
 */

public class StringReverse {
	public String stringRever(String s) {
		StringBuilder sb = new StringBuilder(s);
		String newString = sb.reverse().toString();
		return newString;
	}

	@Test
	public void main() {
		System.out.println(stringRever("hello"));
	}

}

猜你喜欢

转载自blog.csdn.net/weixin_39737132/article/details/89326705