反转字符串
package test;
public class ReverseString {
//java implements
public static String reverseString(String str){
if(str==null || str.length()==0)
return str;
char[] array = str.toCharArray();
int i=0, j=array.length-1;
while(i<j){
char temp = array[i];
array[i] = array[j];
array[j] = temp;
i++;
j--;
}
return new String(array);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
String case1 = null;
String case2 = "";
String case3 = "a";
String case4 = "abcde";
String result = reverseString(case4);
System.out.println(case3);
}
}