package com.gg.test;
/**
*字符反转输出
*思路:split()方法空格为条件,拆分字符串数组,
*然后倒置输出
*/
public class CharReverse
{
public static void main(String[] args){
String str ="I LOVE YOU.";
Reverse(str);
}
//Use String
public static void Reverse(String str){
String str1="";
//char[] ch = String.toCharArray();
String[] strs = str.split("");
for(int i=strs.length-1;i>=0;i--){//反转遍历
//str1+=ch[i];
str1+=strs[i]+"";
}
System.out.println(str1);
}
/*Use StringBuffer
public static void Reverse(String str){
StringBuffer sb = new StringBuffer(str.length());
for(int i = Str.length()-1;i>=0;i--){
sb.append(str.charAt(i));
}
System.out.println(sb.toString());
}
*/
}