public class ReverseString { public static void main(String []args){ System.out.print(method("hello 你是")); } public static String method(String str){ int i=0; int j=str.length()-1; char[] strs=str.toCharArray(); while(i<j){ char temp=strs[j]; strs[j]=strs[i]; strs[i]=temp; i++; j--; } StringBuffer sb=new StringBuffer(); for(char c:strs){ sb.append(c); } return sb.toString(); } }
反转String
最新推荐文章于 2022-06-19 10:59:13 发布