如何逆转字符串,实现I am a student转成student a am I

package cn.wicher.vip;

import java.util.Stack;

public class stringdemo {
	public static void main(String[] args) {
		String s="I am a student";
		String[] split = s.split(" ");//通过空格分割出字符串数组
		StringBuilder stringBuilder=new StringBuilder();
		Stack stack=new Stack();//创建一个栈对象
		for(int i=0;i
思路:利用栈先进后出的思想,再配合string类及stringbuffer类的一些方法还是比较好实现的。

你可能感兴趣的:(算法,面试题)